From 5de56efaad908f2b731a7eda2b9ca2a9196f820a Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 12 Apr 2013 20:10:58 -0600 Subject: 2to3: Apply itertools fixer. In Python 3 zip, map, and filter are all iterators, consequently the itertools variants izip, imap, and ifilter have been removed and the itertools fixer replaces them with the unprefixed names. Because the places where the iterator variants are used in current look like places where the iterator version might be useful, the approach taken here is to define the prefixed versions to the unprefixed versions for Python 3, but otherwise import them from itertools. Closes #3233. --- numpy/lib/npyio.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'numpy/lib/npyio.py') diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 600ab4a36..ea8d98656 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -24,8 +24,10 @@ from io import BytesIO if sys.version_info[0] >= 3: import pickle + imap = map else: import cPickle as pickle + imap = itertools.imap loads = pickle.loads @@ -1607,7 +1609,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, converter.iterupgrade(current_column) except ConverterLockError: errmsg = "Converter #%i is locked and cannot be upgraded: " % i - current_column = itertools.imap(itemgetter(i), rows) + current_column = imap(itemgetter(i), rows) for (j, value) in enumerate(current_column): try: converter.upgrade(value) -- cgit v1.2.1