Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r94351:3f46c49c65fa Date: 2018-04-16 17:45 +0200 http://bitbucket.org/pypy/pypy/changeset/3f46c49c65fa/
Log: update to cffi/17c94f9cb463 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()) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit