summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorMathieu Sornay <mathieu.sornay@cardiologs.com>2018-01-31 16:58:56 +0100
committerMathieu Sornay <mathieu.sornay@cardiologs.com>2018-02-05 11:12:17 +0100
commitc45e445e9fe6bd264aba5a1736f0145ca7bdacc9 (patch)
treeb85e43d172ef88b997e5a9cf781e4678d71a66a4 /numpy/lib/tests
parent9404833f9d3c5c02eae6713433a0db081a6f2572 (diff)
downloadnumpy-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/tests')
-rw-r--r--numpy/lib/tests/test_io.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index a274636da..277569e10 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -1073,6 +1073,13 @@ class Testfromregex(object):
x = np.fromregex(path, regexp, dt, encoding='UTF-8')
assert_array_equal(x, a)
+ def test_compiled_bytes(self):
+ regexp = re.compile(b'(\\d)')
+ c = BytesIO(b'123')
+ dt = [('num', np.float64)]
+ a = np.array([1, 2, 3], dtype=dt)
+ x = np.fromregex(c, regexp, dt)
+ assert_array_equal(x, a)
#####--------------------------------------------------------------------------
@@ -1982,7 +1989,7 @@ M 33 21.99
utf8.encode(encoding)
except (UnicodeError, ImportError):
raise SkipTest('Skipping test_utf8_file_nodtype_unicode, '
- 'unable to encode utf8 in preferred encoding')
+ 'unable to encode utf8 in preferred encoding')
with temppath() as path:
with io.open(path, "wt") as f: