Skip to content

Commit

Permalink
Merge pull request pythonprofilers#112 from Streppel/master
Browse files Browse the repository at this point in the history
updated python version verification so it doesn't break on future pyt…
  • Loading branch information
fabianp committed Jan 17, 2016
2 parents c08a886 + d52f82a commit 796d0be
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions memory_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
line_cell_magic = lambda func: func
magics_class = lambda cls: cls

PY3 = sys.version_info[0] == 3
PY2 = sys.version_info[0] == 2

_TWO_20 = float(2 ** 20)

if PY3:
if PY2:
import __builtin__ as builtins
else:
import builtins
def unicode(x): return str(x)
else:
import __builtin__ as builtins

# .. get available packages ..
try:
Expand Down Expand Up @@ -903,18 +903,18 @@ def inner_wrapper(f):
# globally defined (global variables is not enough
# for all cases, e.g. a script that imports another
# script where @profile is used)
if PY3:
if PY2:
def exec_with_profiler(filename, profiler):
builtins.__dict__['profile'] = profiler
# shadow the profile decorator defined above
ns = dict(_CLEAN_GLOBALS, profile=profiler)
with open(filename) as f:
exec(compile(f.read(), filename, 'exec'), ns, ns)
execfile(filename, ns, ns)
else:
def exec_with_profiler(filename, profiler):
builtins.__dict__['profile'] = profiler
# shadow the profile decorator defined above
ns = dict(_CLEAN_GLOBALS, profile=profiler)
execfile(filename, ns, ns)
with open(filename) as f:
exec(compile(f.read(), filename, 'exec'), ns, ns)


class LogFile(object):
Expand Down

0 comments on commit 796d0be

Please sign in to comment.