Author: Matti Picus <matti.pi...@gmail.com>
Branch: 
Changeset: r87850:d9effc59778a
Date: 2016-10-17 22:53 +0300
http://bitbucket.org/pypy/pypy/changeset/d9effc59778a/

Log:    hack around failure to wrap __buffer__ in cf68a51fde59

diff --git a/pypy/module/cpyext/buffer.py b/pypy/module/cpyext/buffer.py
--- a/pypy/module/cpyext/buffer.py
+++ b/pypy/module/cpyext/buffer.py
@@ -2,6 +2,7 @@
 from pypy.module.cpyext.api import (
     cpython_api, CANNOT_FAIL, Py_TPFLAGS_HAVE_NEWBUFFER)
 from pypy.module.cpyext.pyobject import PyObject
+from pypy.module.cpyext.bytesobject import PyBytesObject
 
 @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
 def PyObject_CheckBuffer(space, pyobj):
@@ -10,6 +11,10 @@
     flags = pyobj.c_ob_type.c_tp_flags
     if (flags & Py_TPFLAGS_HAVE_NEWBUFFER and as_buffer.c_bf_getbuffer):
         return 1
+    name = rffi.charp2str(pyobj.c_ob_type.c_tp_name)
+    if  name in ('str', 'bytes'):
+        # XXX remove once wrapper of __buffer__ -> bf_getbuffer works
+        return 1
     return 0  
 
     
diff --git a/pypy/module/cpyext/test/test_memoryobject.py 
b/pypy/module/cpyext/test/test_memoryobject.py
--- a/pypy/module/cpyext/test/test_memoryobject.py
+++ b/pypy/module/cpyext/test/test_memoryobject.py
@@ -8,7 +8,6 @@
 only_pypy ="config.option.runappdirect and '__pypy__' not in 
sys.builtin_module_names" 
 
 class TestMemoryViewObject(BaseApiTest):
-    skip('needs c_bf_getbuffer wrapper from slotdefs')
     def test_fromobject(self, space, api):
         w_hello = space.newbytes("hello")
         assert api.PyObject_CheckBuffer(w_hello)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to