diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-04-06 19:09:17 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-04-06 19:09:17 -0600 |
commit | aab46a78cefe9fbd46104496ffad17667784a3f5 (patch) | |
tree | 1385a8433047a5cb92f3dcf3b2af12ca02b0025d /numpy/core/_internal.py | |
parent | 3c70e20a5f1aed4098ba66d21e6a1f60edc6fddd (diff) | |
download | numpy-aab46a78cefe9fbd46104496ffad17667784a3f5.tar.gz |
2to3: apply `dict` fixer.
In Python3 `dict.items()`, `dict.keys()`, and `dict.values()` are
iterators. This causes problems when a list is needed so the 2to3 fixer
explicitly constructs a list when is finds on of those functions.
However, that is usually not necessary, so a lot of the work here has
been cleaning up those places where the fix is not needed. The big
exception to that is the `numpy/f2py/crackfortran.py` file. The code
there makes extensive use of loops that modify the contents of the
dictionary being looped through, which raises an error. That together
with the obscurity of the code in that file made it safest to let the
`dict` fixer do its worst.
Closes #3050.
Diffstat (limited to 'numpy/core/_internal.py')
-rw-r--r-- | numpy/core/_internal.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 5115975c2..292dfb8be 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -20,7 +20,7 @@ else: def _makenames_list(adict, align): from .multiarray import dtype allfields = [] - fnames = adict.keys() + fnames = list(adict.keys()) for fname in fnames: obj = adict[fname] n = len(obj) @@ -332,7 +332,7 @@ _pep3118_native_map = { 'O': 'O', 'x': 'V', # padding } -_pep3118_native_typechars = ''.join(_pep3118_native_map.keys()) +_pep3118_native_typechars = ''.join(list(_pep3118_native_map.keys())) _pep3118_standard_map = { '?': '?', @@ -356,7 +356,7 @@ _pep3118_standard_map = { 'O': 'O', 'x': 'V', # padding } -_pep3118_standard_typechars = ''.join(_pep3118_standard_map.keys()) +_pep3118_standard_typechars = ''.join(list(_pep3118_standard_map.keys())) def _dtype_from_pep3118(spec, byteorder='@', is_subdtype=False): from numpy.core.multiarray import dtype @@ -505,7 +505,7 @@ def _dtype_from_pep3118(spec, byteorder='@', is_subdtype=False): offset += extra_offset # Check if this was a simple 1-item type - if len(fields.keys()) == 1 and not explicit_name and fields['f0'][1] == 0 \ + if len(list(fields.keys())) == 1 and not explicit_name and fields['f0'][1] == 0 \ and not is_subdtype: ret = fields['f0'][0] else: |