summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gr?nholm <alex.gronholm@nextday.fi>2011-01-08 16:38:54 +0000
committerAlex Gr?nholm <alex.gronholm@nextday.fi>2011-01-08 16:38:54 +0000
commit0c7cc019eeaf0ef5e894b714141276575d8d6d73 (patch)
treef956aea9c56cdea13d98bbeab7eabd8b8279fee7
parent24c67fca69098b451bda609fe939a4e16e19288c (diff)
downloadfutures-0c7cc019eeaf0ef5e894b714141276575d8d6d73.tar.gz
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)
-rw-r--r--concurrent/futures/_compat.py10
1 files 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]