|
31 | 31 | line_cell_magic = lambda func: func |
32 | 32 | magics_class = lambda cls: cls |
33 | 33 |
|
34 | | -PY3 = sys.version_info[0] == 3 |
| 34 | +PY2 = sys.version_info[0] == 2 |
35 | 35 |
|
36 | 36 | _TWO_20 = float(2 ** 20) |
37 | 37 |
|
38 | | -if PY3: |
| 38 | +if PY2: |
| 39 | + import __builtin__ as builtins |
| 40 | +else: |
39 | 41 | import builtins |
40 | 42 | def unicode(x): return str(x) |
41 | | -else: |
42 | | - import __builtin__ as builtins |
43 | 43 |
|
44 | 44 | # .. get available packages .. |
45 | 45 | try: |
@@ -903,18 +903,18 @@ def inner_wrapper(f): |
903 | 903 | # globally defined (global variables is not enough |
904 | 904 | # for all cases, e.g. a script that imports another |
905 | 905 | # script where @profile is used) |
906 | | -if PY3: |
| 906 | +if PY2: |
907 | 907 | def exec_with_profiler(filename, profiler): |
908 | 908 | builtins.__dict__['profile'] = profiler |
909 | | - # shadow the profile decorator defined above |
910 | 909 | ns = dict(_CLEAN_GLOBALS, profile=profiler) |
911 | | - with open(filename) as f: |
912 | | - exec(compile(f.read(), filename, 'exec'), ns, ns) |
| 910 | + execfile(filename, ns, ns) |
913 | 911 | else: |
914 | 912 | def exec_with_profiler(filename, profiler): |
915 | 913 | builtins.__dict__['profile'] = profiler |
| 914 | + # shadow the profile decorator defined above |
916 | 915 | ns = dict(_CLEAN_GLOBALS, profile=profiler) |
917 | | - execfile(filename, ns, ns) |
| 916 | + with open(filename) as f: |
| 917 | + exec(compile(f.read(), filename, 'exec'), ns, ns) |
918 | 918 |
|
919 | 919 |
|
920 | 920 | class LogFile(object): |
|
0 commit comments