mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue 2903: Add __name__ in globals for namedtuple namespace.
This commit is contained in:
parent
d99bee7c9f
commit
3c2523c2eb
1 changed files with 3 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue