Title: execfile conversion is not correct
Type: Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.0
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, fabioz
Priority: normal Keywords:

Created on 2008-12-22 11:24 by fabioz, last changed 2008-12-22 20:03 by benjamin.peterson. This issue is now closed.

Messages (2)
msg78170 - (view) Author: Fabio Zadrozny (fabioz) * Date: 2008-12-22 11:24
In 2to3, execfile(file, globals, locals) is translated to 

exec(open(file).read(), globals, locals)

But that's not correct, as the actual file from the executed code gets
wrong with that.

The correct thing would be:

exec(compile(open(file).read(), file, 'exec'), globals, locals)

So that the name of the file remains correct in the module that's being run.
msg78208 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-12-22 20:03
Fixed in r67900.
Date User Action Args
2008-12-22 20:03:06benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg78208
nosy: + benjamin.peterson
2008-12-22 11:24:57fabiozcreate