mirror of https://github.com/python/cpython
Issue 2903: Add __name__ in globals for namedtuple namespace.
This commit is contained in:
parent
d99bee7c9f
commit
3c2523c2eb
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue