classification
Title: Add __name__ in globals of generated namedtuple namespace
Type: Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: rhettinger, xilun
Priority: normal Keywords: patch

Created on 2008-05-18 03:12 by xilun, last changed 2008-05-30 07:19 by rhettinger. This issue is now closed.

Files
File name Uploaded Description Edit
collections.r59898.patch xilun, 2008-05-18 03:12
Messages (2)
msg67022 - (view) Author: Guillaume Knispel (xilun) Date: 2008-05-18 03:12
Some 3rd party tracers rely on frame.f_globals["__name__"] to be set to
the module name that contains the code currently executed.
frame.f_globals["__name__"] is not defined when some code has been
generated with exec, which is the way namedtuples are created.

The attached patch set __name__ to '__generated_%s__' % typename in the
generated namespace, which is quite handy to see where the code comes
from. Indeed if sys._getframe is available it sets __name__ to
'__generated_%s__%s__' % (typename, result.__module__) which is even
more useful.
msg67523 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-05-30 07:17
Added the simpler first part of the patch in r63807.
Thanks for the submission.
History
Date User Action Args
2008-05-30 07:19:18rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg67523
2008-05-18 19:55:04georg.brandlsetassignee: rhettinger
nosy: + rhettinger
2008-05-18 03:12:28xiluncreate