Author: Brian Kearns <bdkea...@gmail.com>
Branch: refactor-buffer-api
Changeset: r70938:4027486ec885
Date: 2014-04-24 16:34 -0400
http://bitbucket.org/pypy/pypy/changeset/4027486ec885/

Log:    replace usage of bufferstr_w in marshal

diff --git a/pypy/module/marshal/interp_marshal.py 
b/pypy/module/marshal/interp_marshal.py
--- a/pypy/module/marshal/interp_marshal.py
+++ b/pypy/module/marshal/interp_marshal.py
@@ -476,13 +476,7 @@
     # Unmarshaller with inlined buffer string
     def __init__(self, space, w_str):
         Unmarshaller.__init__(self, space, None)
-        try:
-            self.bufstr = space.bufferstr_w(w_str)
-        except OperationError, e:
-            if not e.match(space, space.w_TypeError):
-                raise
-            raise OperationError(space.w_TypeError, space.wrap(
-                'marshal.loads() arg must be string or buffer'))
+        self.bufstr = space.getarg_w('s#', w_str)
         self.bufpos = 0
         self.limit = len(self.bufstr)
 
diff --git a/pypy/module/marshal/test/test_marshal.py 
b/pypy/module/marshal/test/test_marshal.py
--- a/pypy/module/marshal/test/test_marshal.py
+++ b/pypy/module/marshal/test/test_marshal.py
@@ -14,6 +14,10 @@
         print(repr(s))
         x = marshal.loads(s)
         assert x == case and type(x) is type(case)
+
+        exc = raises(TypeError, marshal.loads, memoryview(s))
+        assert str(exc.value) == "must be string or read-only buffer, not 
memoryview"
+
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to