This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: execfile conversion is not correct
Type: Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.0
process
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 2022-04-11 14:56 by admin. 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.
History
Date User Action Args
2022-04-11 14:56:43adminsetgithub: 48967
2008-12-22 20:03:06benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg78208
nosy: + benjamin.peterson
2008-12-22 11:24:57fabiozcreate