diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-05-14 15:55:41 -0500 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2020-05-18 16:44:26 -0500 |
commit | 8bc4701bbfbcfafb2be634d41a2611bd0182d344 (patch) | |
tree | 118258b5b57b57ea71a88a5be9cb9df50e50f5fd /numpy/lib/_iotools.py | |
parent | 77410e26dd94bdd07df096be06ee9aa7d5738ce6 (diff) | |
download | numpy-8bc4701bbfbcfafb2be634d41a2611bd0182d344.tar.gz |
BUG: Fix default fallback in genfromtxt
This affected (for example?) if the `dtype=object` was used
without a converter, meaning that the default one is used.
And this is currently the last one, which is `string_` (and thus
bytes).
Closes gh-16189
Diffstat (limited to 'numpy/lib/_iotools.py')
-rw-r--r-- | numpy/lib/_iotools.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py index 84aff5e5d..ac5f4f9b4 100644 --- a/numpy/lib/_iotools.py +++ b/numpy/lib/_iotools.py @@ -506,13 +506,15 @@ class StringConverter: _mapper.extend([(nx.float64, float, nx.nan), (nx.complex128, complex, nx.nan + 0j), (nx.longdouble, nx.longdouble, nx.nan), - (nx.unicode_, asunicode, '???'), - (nx.string_, asbytes, '???'), # If a non-default dtype is passed, fall back to generic # ones (should only be used for the converter) (nx.integer, int, -1), (nx.floating, float, nx.nan), - (nx.complexfloating, complex, nx.nan + 0j),]) + (nx.complexfloating, complex, nx.nan + 0j), + # Last, try with the string types (must be last, because + # `_mapper[-1]` is used as default in some cases) + (nx.unicode_, asunicode, '???'), + (nx.string_, asbytes, '???'),]) @classmethod def _getdtype(cls, val): |