Issue 2903: Add __name__ in globals for namedtuple namespace.

This commit is contained in:
Raymond Hettinger 2008-05-30 07:16:53 +00:00
parent d99bee7c9f
commit 3c2523c2eb
1 changed files with 3 additions and 2 deletions

View File

@ -88,8 +88,9 @@ def namedtuple(typename, field_names, verbose=False):
if verbose:
print template
# Execute the template string in a temporary namespace
namespace = dict(itemgetter=_itemgetter)
# Execute the template string in a temporary namespace and
# support tracing utilities by setting a value for frame.f_globals['__name__']
namespace = dict(itemgetter=_itemgetter, __name__='namedtuple_%s' % typename)
try:
exec template in namespace
except SyntaxError, e: