Skip to content

ipython32 %run -d breaks with NameError name 'execfile' is not defined #1421

Closed
ShereKahn opened this Issue Feb 19, 2012 · 2 comments

3 participants

@ShereKahn
In [175]: %run -d -b109 parser
Breakpoint 1 at /Users/ShereKahn/Prog/Clojure/Alatar/Data/parser.py:109
NOTE: Enter 'c' at the ipdb>  prompt to start your script.
> <string>(1)<module>()

ipdb> c
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
NameError: name 'execfile' is not defined
@takluyver
IPython member

Looks like there's a few stray execfiles that weren't taken care of for Python 3.

I'm marking this quickfix, since it should be relatively easy to refer them to execfile in py3compat.

We're having an introduction to contributing to open source Python projects on the 28th, so I'm asking people to leave this (and other quickfix bugs) for people to fix at that evening. If it's an urgent problem, you can of course patch your own installation.

@yigiter
yigiter commented Mar 6, 2012

In case anybody needs, here is the quickfix:

Modify the following 2 lines in /core/magic.py as shown below:
Line 1488:
#arg_str = 'execfile(filename,prog_ns)'
arg_str = 'exec(compile(open(filename).read(), filename, "exec"), prog_ns)'

Line 1798:
#deb.run('execfile("%s")' % filename, prog_ns)
deb.run('exec(compile(open("%s").read(), "%s", "exec"))' %(filename,filename), prog_ns)

@takluyver takluyver added a commit that closed this issue Apr 15, 2012
@takluyver takluyver Fix for %run -d on Python 3
Closes gh-1421
3e1a509
@takluyver takluyver closed this in 3e1a509 Apr 15, 2012
@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
@takluyver takluyver Fix for %run -d on Python 3
Closes gh-1421
cfbe2c4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.