Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

don't override execfile on Python 2 #778

Merged
merged 1 commit into from

2 participants

@minrk
Owner

py3compat.execfile() specifies an encoding for a file, but Python 2's execfile respects the # coding: headers. In the long run, py3compat.execfile() should respect the coding header, but for now, just don't override the existing execfile.

@fperez
Owner

please go ahead and merge this, yes! Thanks for catching it...

@minrk minrk merged commit e8613d2 into ipython:master
@ellisonbg ellisonbg referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 9, 2011
  1. @minrk
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 3 deletions.
  1. +7 −3 IPython/utils/py3compat.py
View
10 IPython/utils/py3compat.py
@@ -46,6 +46,10 @@ def isidentifier(s, dotted=False):
open = orig_open
MethodType = types.MethodType
+
+ def execfile(fname, glob, loc=None):
+ loc = loc if (loc is not None) else glob
+ exec compile(open(fname).read(), fname, 'exec') in glob, loc
else:
PY3 = False
@@ -89,7 +93,7 @@ def __exit__(self, etype, value, traceback):
def MethodType(func, instance):
return types.MethodType(func, instance, type(instance))
+
+ # don't override system execfile on 2.x:
+ execfile = execfile
-def execfile(fname, glob, loc=None):
- loc = loc if (loc is not None) else glob
- exec compile(open(fname).read(), fname, 'exec') in glob, loc
Something went wrong with that request. Please try again.