Author: Matti Picus <[email protected]>
Branch: memoryview-attributes
Changeset: r86388:70768dcd906f
Date: 2016-08-22 11:08 +1000
http://bitbucket.org/pypy/pypy/changeset/70768dcd906f/
Log: __buffer__ is a method with a flags arg, not an attibute
diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -167,8 +167,8 @@
else:
return self.value
- def __buffer__(self):
- return buffer(self._buffer)
+ def __buffer__(self, flags):
+ return buffer(self._buffer, flags)
def _get_b_base(self):
try:
diff --git a/pypy/module/cpyext/test/buffer_test.c
b/pypy/module/cpyext/test/buffer_test.c
--- a/pypy/module/cpyext/test/buffer_test.c
+++ b/pypy/module/cpyext/test/buffer_test.c
@@ -31,9 +31,9 @@
/* tools to print the array */
char* stringify(MyArray* a, int nmax){
char* output = (char*) malloc(nmax * 20);
- int pos = sprintf(&output[0], "[");
+ int k, pos = sprintf(&output[0], "[");
- for (int k=0; k < a->length && k < nmax; k++){
+ for (k=0; k < a->length && k < nmax; k++){
pos += sprintf(&output[pos], " %d", a->arr[k]);
}
if(a->length > nmax)
diff --git a/pypy/module/micronumpy/ctors.py b/pypy/module/micronumpy/ctors.py
--- a/pypy/module/micronumpy/ctors.py
+++ b/pypy/module/micronumpy/ctors.py
@@ -468,7 +468,7 @@
except OperationError as e:
if not e.match(space, space.w_TypeError):
raise
- w_buffer = space.getattr(w_buffer, space.wrap('__buffer__'))
+ w_buffer = space.call_method(w_buffer, '__buffer__', 0)
buf = _getbuffer(space, w_buffer)
ts = buf.getlength()
diff --git a/pypy/module/micronumpy/test/test_ndarray.py
b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -3626,7 +3626,8 @@
assert str(exc.value) == "assignment destination is read-only"
class A(object):
- __buffer__ = 'abc'
+ def __buffer__(self, flags):
+ return 'abc'
data = A()
a = np.frombuffer(data, 'c')
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -464,8 +464,8 @@
raise oefmt(space.w_TypeError,
"Cannot use string as modifiable buffer")
- def descr_getbuffer(self, space):
- return self
+ def descr_getbuffer(self, space, w_flags):
+ return StringBuffer(self._value)
charbuf_w = str_w
diff --git a/pypy/objspace/std/test/test_bufferobject.py
b/pypy/objspace/std/test/test_bufferobject.py
--- a/pypy/objspace/std/test/test_bufferobject.py
+++ b/pypy/objspace/std/test/test_bufferobject.py
@@ -4,7 +4,7 @@
def test_init(self):
import sys
class A(object):
- def __buffer__(self):
+ def __buffer__(self, flags):
return buffer('123')
if '__pypy__' not in sys.builtin_module_names:
raises(TypeError, buffer, A())
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit