]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue 2903: Add __name__ in globals for namedtuple namespace.
authorRaymond Hettinger <python@rcn.com>
Fri, 30 May 2008 07:16:53 +0000 (07:16 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 30 May 2008 07:16:53 +0000 (07:16 +0000)
Lib/collections.py

index b03a733e7b1d6e0586b35597013b2e2f9af8aba4..f6233a7a44896ddca874eb1abdfdc7fd19b86ccb 100644 (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: