[pypy-commit] pypy refactor-buffer-api: Fall back to calling app-level __buffer__ when it's not possible to call the interp-level buffer API.
Manuel Jacob
noreply at buildbot.pypy.org
Wed Nov 20 19:41:10 CET 2013
Author: Manuel Jacob
Branch: refactor-buffer-api
Changeset: r68261:456bc410dd3a
Date: 2013-11-20 19:40 +0100
http://bitbucket.org/pypy/pypy/changeset/456bc410dd3a/
Log: Fall back to calling app-level __buffer__ when it's not possible to
call the interp-level buffer API.
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -197,6 +197,12 @@
return None
def buffer_w(self, space):
+ from pypy.module.__builtin__.interp_memoryview import W_Buffer
+ w_impl = space.lookup(self, '__buffer__')
+ if w_impl is not None:
+ w_result = space.get_and_call_function(w_impl, self)
+ if isinstance(w_result, W_Buffer):
+ return w_result.buf
self._typed_unwrap_error(space, "buffer")
def str_w(self, space):
More information about the pypy-commit
mailing list