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:
|
if verbose:
|
||||||
print template
|
print template
|
||||||
|
|
||||||
# Execute the template string in a temporary namespace
|
# Execute the template string in a temporary namespace and
|
||||||
namespace = dict(itemgetter=_itemgetter)
|
# support tracing utilities by setting a value for frame.f_globals['__name__']
|
||||||
|
namespace = dict(itemgetter=_itemgetter, __name__='namedtuple_%s' % typename)
|
||||||
try:
|
try:
|
||||||
exec template in namespace
|
exec template in namespace
|
||||||
except SyntaxError, e:
|
except SyntaxError, e:
|
||||||
|
|
Loading…
Reference in New Issue