[Python-checkins] cpython: Move namespace setup inside the template.
raymond.hettinger
python-checkins at python.org
Wed Mar 23 21:05:22 CET 2011
http://hg.python.org/cpython/rev/7208f7502207
changeset: 68878:7208f7502207
parent: 68868:267578b2422d
user: Raymond Hettinger <python at rcn.com>
date: Wed Mar 23 11:49:56 2011 -0700
summary:
Move namespace setup inside the template.
files:
Lib/collections/__init__.py | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -234,6 +234,12 @@
################################################################################
_class_template = '''\
+__name__ = 'namedtuple_{typename}'
+
+from builtins import property as _property, tuple as _tuple
+from operator import itemgetter as _itemgetter
+from collections import OrderedDict
+
class {typename}(tuple):
'{typename}({arg_list})'
@@ -349,8 +355,7 @@
# Execute the class definition 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,
- OrderedDict=OrderedDict, _property=property, _tuple=tuple)
+ namespace = {}
try:
exec(class_definition, namespace)
except SyntaxError as e:
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list