diff options
author | Mathieu Sornay <mathieu.sornay@cardiologs.com> | 2018-01-31 16:58:56 +0100 |
---|---|---|
committer | Mathieu Sornay <mathieu.sornay@cardiologs.com> | 2018-02-05 11:12:17 +0100 |
commit | c45e445e9fe6bd264aba5a1736f0145ca7bdacc9 (patch) | |
tree | b85e43d172ef88b997e5a9cf781e4678d71a66a4 /numpy/lib/npyio.py | |
parent | 9404833f9d3c5c02eae6713433a0db081a6f2572 (diff) | |
download | numpy-c45e445e9fe6bd264aba5a1736f0145ca7bdacc9.tar.gz |
BUG: fromregex: asbytes called on regexp objects
When calling fromregex() with a binary stream and a regular expression
object, asbytes() was called on the regexp object, resulting in an
incorrect regular expression being compiled and used.
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 9ee0aaaae..02d68bc9e 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1459,9 +1459,9 @@ def fromregex(file, regexp, dtype, encoding=None): dtype = np.dtype(dtype) content = file.read() - if isinstance(content, bytes) and not isinstance(regexp, bytes): + if isinstance(content, bytes) and isinstance(regexp, np.unicode): regexp = asbytes(regexp) - elif not isinstance(content, bytes) and isinstance(regexp, bytes): + elif isinstance(content, np.unicode) and isinstance(regexp, bytes): regexp = asstr(regexp) if not hasattr(regexp, 'match'): |