From 0c7cc019eeaf0ef5e894b714141276575d8d6d73 Mon Sep 17 00:00:00 2001 From: Alex Gr?nholm Date: Sat, 8 Jan 2011 16:38:54 +0000 Subject: Changed the namedtuple implementation so it will compile on Python 3.1 (even though it's never imported, it's still compiled on setup.py install) --- concurrent/futures/_compat.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/concurrent/futures/_compat.py b/concurrent/futures/_compat.py index 9a9ed7c..1146232 100644 --- a/concurrent/futures/_compat.py +++ b/concurrent/futures/_compat.py @@ -2,7 +2,8 @@ from keyword import iskeyword as _iskeyword from operator import itemgetter as _itemgetter import sys as _sys -def namedtuple(typename, field_names, verbose=False): + +def namedtuple(typename, field_names): """Returns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', 'x y') @@ -79,16 +80,15 @@ def namedtuple(typename, field_names, verbose=False): return tuple(self) \n\n''' % locals() for i, name in enumerate(field_names): template += ' %s = _property(_itemgetter(%d))\n' % (name, i) - if verbose: - print template # 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, _property=property, _tuple=tuple) try: - exec template in namespace - except SyntaxError, e: + exec(template, namespace) + except SyntaxError: + e = _sys.exc_info()[1] raise SyntaxError(e.message + ':\n' + template) result = namespace[typename] -- cgit v1.2.1