From: Raymond Hettinger Date: Fri, 30 May 2008 07:16:53 +0000 (+0000) Subject: Issue 2903: Add __name__ in globals for namedtuple namespace. X-Git-Tag: v2.6b1~198 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3c2523c2eb9de8a05e00c08e83f6b2165020c627;p=thirdparty%2FPython%2Fcpython.git Issue 2903: Add __name__ in globals for namedtuple namespace. --- diff --git a/Lib/collections.py b/Lib/collections.py index b03a733e7b1d..f6233a7a4489 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -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: