[pypy-commit] pypy default: declare array.array to be a read-write buffer. Fixes issue #2751
cfbolz
pypy.commits at gmail.com
Wed Feb 28 10:33:56 EST 2018
Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch:
Changeset: r93906:7c772420134d
Date: 2018-02-28 16:30 +0100
http://bitbucket.org/pypy/pypy/changeset/7c772420134d/
Log: declare array.array to be a read-write buffer. Fixes issue #2751
diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -711,7 +711,7 @@
return space.newtext(s)
W_ArrayBase.typedef = TypeDef(
- 'array.array',
+ 'array.array', None, None, "read-write",
__new__ = interp2app(w_array),
__len__ = interp2app(W_ArrayBase.descr_len),
diff --git a/pypy/module/cpyext/test/test_abstract.py b/pypy/module/cpyext/test/test_abstract.py
--- a/pypy/module/cpyext/test/test_abstract.py
+++ b/pypy/module/cpyext/test/test_abstract.py
@@ -96,6 +96,16 @@
assert raises(TypeError, buffer_support.writebuffer_as_string, ro_mm)
assert s == buffer_support.charbuffer_as_string(ro_mm)
+ def test_array(self):
+ import array
+ buffer_support = self.get_buffer_support()
+
+ s = 'a\0x'
+ a = array.array('B', [5, 0, 10])
+
+ buffer_support.zero_out_writebuffer(a)
+ assert list(a) == [0, 0, 0]
+
def test_nonbuffer(self):
# e.g. int
buffer_support = self.get_buffer_support()
More information about the pypy-commit
mailing list