Author: Armin Rigo <[email protected]>
Branch:
Changeset: r93576:ca3a17a0ae22
Date: 2017-12-26 08:28 +0100
http://bitbucket.org/pypy/pypy/changeset/ca3a17a0ae22/
Log: Issue #2714
Test and fix for regression introduced in e0fe31dff118
diff --git a/lib_pypy/_ctypes/array.py b/lib_pypy/_ctypes/array.py
--- a/lib_pypy/_ctypes/array.py
+++ b/lib_pypy/_ctypes/array.py
@@ -12,7 +12,8 @@
if cls == (_CData,): # this is the Array class defined below
res._ffiarray = None
return res
- if not hasattr(res, '_length_') or not isinstance(res._length_, int):
+ if not hasattr(res, '_length_') or not isinstance(res._length_,
+ (int, long)):
raise AttributeError(
"class must define a '_length_' attribute, "
"which must be a positive integer")
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_buffers.py
b/pypy/module/test_lib_pypy/ctypes_tests/test_buffers.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_buffers.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_buffers.py
@@ -9,6 +9,11 @@
assert sizeof(b) == 32 * sizeof(c_char)
assert type(b[0]) is str
+ b = create_string_buffer(33L)
+ assert len(b) == 33
+ assert sizeof(b) == 33 * sizeof(c_char)
+ assert type(b[0]) is str
+
b = create_string_buffer("abc")
assert len(b) == 4 # trailing nul char
assert sizeof(b) == 4 * sizeof(c_char)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit