Skip to content

Commit

Permalink
Merge pull request #789 from benoitc/fix/787
Browse files Browse the repository at this point in the history
fix #787 check if we load a pyc file or not.
  • Loading branch information
benoitc committed Jun 16, 2014
2 parents 944e224 + f3824a0 commit 42c16b1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gunicorn/six.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,11 @@ def reraise(tp, value, tb=None):
print_ = getattr(builtins, "print")

def execfile_(fname, *args):
return exec_(_get_codeobj(fname), *args)
if fname.endswith(".pyc"):
code = _get_codeobj(fname)
else:
code = compile(open(fname, 'rb').read(), fname, 'exec')
return exec_(code, *args)


del builtins
Expand All @@ -382,7 +386,9 @@ def exec_(code, globs=None, locs=None):

def execfile_(fname, *args):
""" Overriding PY2 execfile() implementation to support .pyc files """
return exec_(_get_codeobj(fname), *args)
if fname.endswith(".pyc"):
return exec_(_get_codeobj(fname), *args)
return execfile(fname, *args)


def print_(*args, **kwargs):
Expand Down

0 comments on commit 42c16b1

Please sign in to comment.