[issue7268] 2to3 execfile conversion changes behavior
report at bugs.python.org
Fri Nov 6 01:08:56 CET 2009
New submission from flashk <flashk at gmail.com>:
I recently ran 2to3 on some of my scripts and noticed a change in behavior.
I had a script that used the built-in execfile function. After the conversion, it was
changed to manually open the file and read the contents into the exec function. Now I am
getting a SyntaxError with the modified code.
The SyntaxError is caused when the new exec code is called on a script that ends with an
empty indented line. I'm not sure if this is an error with the 2to3 script or the built-
in exec function.
I've attached a very minimal test case. The test.py file is a simple hello world script
that ends with an empty indented line. The execfile_example.py file simply calls
execfile on the test.py script. The execfile_example_converted.py file is the 2to3
converted version of execfile_example.py.
I'm running Python 2.6.2 on Windows XP.
components: 2to3 (2.x to 3.0 conversion tool), Interpreter Core
title: 2to3 execfile conversion changes behavior
versions: Python 2.6
Added file: http://bugs.python.org/file15267/execfile_problem.zip
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list