Author: Ronan Lamy <[email protected]>
Branch: PyBuffer
Changeset: r91100:9cb1ffa41c92
Date: 2017-04-20 15:41 +0100
http://bitbucket.org/pypy/pypy/changeset/9cb1ffa41c92/
Log: Don't crash when calling getarg_w('w*') on a read-only buffer; add
ArrayBuffer.as_binary_rw()
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -10,7 +10,8 @@
from rpython.rlib.rarithmetic import r_uint, SHRT_MIN, SHRT_MAX, \
INT_MIN, INT_MAX, UINT_MAX, USHRT_MAX
-from pypy.interpreter.buffer import SimpleBuffer, StringBuffer
+from pypy.interpreter.buffer import (
+ BufferInterfaceNotFound, SimpleBuffer, StringBuffer)
from pypy.interpreter.executioncontext import (ExecutionContext, ActionFlag,
make_finalizer_queue)
from pypy.interpreter.error import OperationError, new_exception_class, oefmt
@@ -374,9 +375,6 @@
class DescrMismatch(Exception):
pass
-class BufferInterfaceNotFound(Exception):
- pass
-
@specialize.memo()
def wrappable_class_name(Class):
try:
diff --git a/pypy/interpreter/buffer.py b/pypy/interpreter/buffer.py
--- a/pypy/interpreter/buffer.py
+++ b/pypy/interpreter/buffer.py
@@ -5,6 +5,9 @@
from pypy.interpreter.error import oefmt
+class BufferInterfaceNotFound(Exception):
+ pass
+
class PyBuffer(object):
"""Abstract base class for buffers."""
@@ -41,7 +44,7 @@
def as_binary_rw(self):
"""Return a writable BinaryBuffer sharing the same data as `self`."""
- raise NotImplementedError
+ raise BufferInterfaceNotFound
def getformat(self):
raise NotImplementedError
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
@@ -924,6 +924,10 @@
def as_binary(self):
return self.data
+ def as_binary_rw(self):
+ assert not self.readonly
+ return self.data
+
unpack_driver = jit.JitDriver(name='unpack_array',
greens=['selfclass', 'tp'],
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit