[pypy-commit] pypy default: Revert the changes in memoryview.
amauryfa
noreply at buildbot.pypy.org
Sat Jun 13 11:22:37 CEST 2015
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch:
Changeset: r78080:47e51aba1243
Date: 2015-06-13 11:21 +0200
http://bitbucket.org/pypy/pypy/changeset/47e51aba1243/
Log: Revert the changes in memoryview. CPython 2.7.10 changed argument
parsing of the struct module, and also some errors messages.
(checked with running tests with -A, on a CPython-2.7.10
interpreter)
diff --git a/pypy/module/struct/interp_struct.py b/pypy/module/struct/interp_struct.py
--- a/pypy/module/struct/interp_struct.py
+++ b/pypy/module/struct/interp_struct.py
@@ -61,7 +61,7 @@
@unwrap_spec(format=str, offset=int)
def pack_into(space, format, w_buffer, offset, args_w):
res = _pack(space, format, args_w)
- buf = space.writebuf_w(w_buffer)
+ buf = space.getarg_w('w*', w_buffer)
if offset < 0:
offset += buf.getlength()
size = len(res)
diff --git a/pypy/module/struct/test/test_struct.py b/pypy/module/struct/test/test_struct.py
--- a/pypy/module/struct/test/test_struct.py
+++ b/pypy/module/struct/test/test_struct.py
@@ -390,9 +390,9 @@
self.struct.pack("ii", 17, 42) +
'\x00' * (19-sz-2))
exc = raises(TypeError, self.struct.pack_into, "ii", buffer(b), 0, 17, 42)
- assert str(exc.value) == "buffer is read-only"
+ assert str(exc.value) == "argument must be read-write buffer, not buffer"
exc = raises(TypeError, self.struct.pack_into, "ii", 'test', 0, 17, 42)
- assert str(exc.value) == "Cannot use string as modifiable buffer"
+ assert str(exc.value) == "argument must be read-write buffer, not str"
exc = raises(self.struct.error, self.struct.pack_into, "ii", b[0:1], 0, 17, 42)
assert str(exc.value) == "pack_into requires a buffer of at least 8 bytes"
diff --git a/pypy/objspace/std/memoryobject.py b/pypy/objspace/std/memoryobject.py
--- a/pypy/objspace/std/memoryobject.py
+++ b/pypy/objspace/std/memoryobject.py
@@ -23,14 +23,6 @@
space.check_buf_flags(flags, self.buf.readonly)
return self.buf
- def readbuf_w(self, space):
- return self.buf
-
- def writebuf_w(self, space):
- if self.buf.readonly:
- raise oefmt(space.w_TypeError, "buffer is read-only")
- return self.buf
-
@staticmethod
def descr_new_memoryview(space, w_subtype, w_object):
return W_MemoryView(space.buffer_w(w_object, space.BUF_FULL_RO))
More information about the pypy-commit
mailing list