[pypy-commit] pypy py3.5: merge default into py3.5
mattip
pypy.commits at gmail.com
Tue Apr 17 18:01:16 EDT 2018
Author: Matti Picus <matti.picus at gmail.com>
Branch: py3.5
Changeset: r94364:5a7eeaf512fc
Date: 2018-04-18 01:00 +0300
http://bitbucket.org/pypy/pypy/changeset/5a7eeaf512fc/
Log: merge default into py3.5
diff --git a/pypy/module/_cffi_backend/ctypearray.py b/pypy/module/_cffi_backend/ctypearray.py
--- a/pypy/module/_cffi_backend/ctypearray.py
+++ b/pypy/module/_cffi_backend/ctypearray.py
@@ -70,7 +70,15 @@
length = wchar_helper.unicode_size_as_char32(u)
return (w_value, length + 1)
else:
- explicitlength = space.getindex_w(w_value, space.w_OverflowError)
+ try:
+ explicitlength = space.getindex_w(w_value,
+ space.w_OverflowError)
+ except OperationError as e:
+ if e.match(space, space.w_TypeError):
+ raise oefmt(space.w_TypeError,
+ "expected new array length or list/tuple/str, "
+ "not %T", w_value)
+ raise
if explicitlength < 0:
raise oefmt(space.w_ValueError, "negative array length")
return (space.w_None, explicitlength)
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -278,6 +278,9 @@
assert repr(q).startswith("<cdata 'int *' 0x")
assert p == q
assert hash(p) == hash(q)
+ e = py.test.raises(TypeError, newp, new_array_type(BPtr, None), None)
+ assert str(e.value) == (
+ "expected new array length or list/tuple/str, not NoneType")
def test_pointer_bool():
BInt = new_primitive_type("int")
@@ -359,6 +362,9 @@
assert int(c) == ord(b'A')
py.test.raises(TypeError, cast, BChar, b'foo')
py.test.raises(TypeError, cast, BChar, u+'foo')
+ e = py.test.raises(TypeError, newp, new_array_type(BPtr, None), 12.3)
+ assert str(e.value) == (
+ "expected new array length or list/tuple/str, not float")
def test_reading_pointer_to_pointer():
BVoidP = new_pointer_type(new_void_type())
More information about the pypy-commit
mailing list