[New-bugs-announce] [issue4717] execfile conversion is not correct

Fabio Zadrozny report at bugs.python.org
Mon Dec 22 12:24:58 CET 2008

New submission from Fabio Zadrozny <fabioz at users.sourceforge.net>:

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.

components: 2to3 (2.x to 3.0 conversion tool)
messages: 78170
nosy: fabioz
severity: normal
status: open
title: execfile conversion is not correct
versions: Python 3.0

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list