[pypy-commit] pypy cpyext-ext: fill tp_as_buffer slots, starts to fix PyArg_ParseTuple(.. 's*' ..) with bytearray arg
mattip
pypy.commits at gmail.com
Thu Jun 2 00:40:56 EDT 2016
Author: Matti Picus <matti.picus at gmail.com>
Branch: cpyext-ext
Changeset: r84873:46d519f7ebaa
Date: 2016-06-02 07:38 +0300
http://bitbucket.org/pypy/pypy/changeset/46d519f7ebaa/
Log: fill tp_as_buffer slots, starts to fix PyArg_ParseTuple(.. 's*' ..)
with bytearray arg
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -23,6 +23,7 @@
else:
bases = [__base]
self.bases = bases
+ # Used in cpyext to fill tp_as_buffer slots
assert __buffer in {None, 'read-write', 'read'}, "Unknown value for __buffer"
self.buffer = __buffer
self.heaptype = False
diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -44,7 +44,7 @@
return ''.join(self.data)
def nonmovable_carray(self, space):
- return rffi.cast(rffi.CCHARP, 0)
+ return BytearrayBuffer(self.data, False).get_raw_address()
def _new(self, value):
if value is self.data:
@@ -991,7 +991,7 @@
W_BytearrayObject.typedef = TypeDef(
- "bytearray",
+ "bytearray", None, None, "read-write",
__doc__ = BytearrayDocstrings.__doc__,
__new__ = interp2app(W_BytearrayObject.descr_new),
__hash__ = None,
@@ -1250,6 +1250,9 @@
for i in range(len(string)):
self.data[start + i] = string[i]
+ def get_raw_address(self):
+ return rffi.cast(rffi.CCHARP, 0)
+
@specialize.argtype(1)
def _memcmp(selfvalue, buffer, length):
More information about the pypy-commit
mailing list