[pypy-commit] pypy py3k: refactor and allow specifying flags

pjenvey pypy.commits at gmail.com
Mon Apr 18 15:23:02 EDT 2016


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r83751:9a84b699eb82
Date: 2016-04-18 12:22 -0700
http://bitbucket.org/pypy/pypy/changeset/9a84b699eb82/

Log:	refactor and allow specifying flags

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1511,7 +1511,7 @@
             assert False
 
     # XXX rename/replace with code more like CPython getargs for buffers
-    def bufferstr_w(self, w_obj):
+    def bufferstr_w(self, w_obj, flags=BUF_SIMPLE):
         # Directly returns an interp-level str.  Note that if w_obj is a
         # unicode string, this is different from str_w(buffer(w_obj)):
         # indeed, the latter returns a string with the raw bytes from
@@ -1525,13 +1525,7 @@
         except OperationError, e:
             if not e.match(self, self.w_TypeError):
                 raise
-        try:
-            buf = w_obj.buffer_w(self, 0)
-        except BufferInterfaceNotFound:
-            raise oefmt(self.w_TypeError,
-                        "'%T' does not support the buffer interface", w_obj)
-        else:
-            return buf.as_str()
+        return self.buffer_w(w_obj, flags).as_str()
 
     def str_or_None_w(self, w_obj):
         return None if self.is_none(w_obj) else self.str_w(w_obj)


More information about the pypy-commit mailing list