[pypy-commit] pypy default: OperationError -> oefmt in memoryobject.py

Manuel Jacob noreply at buildbot.pypy.org
Thu May 22 04:18:28 CEST 2014


Author: Manuel Jacob
Branch: 
Changeset: r71660:e2f6a65a50a7
Date: 2014-05-22 02:08 +0200
http://bitbucket.org/pypy/pypy/changeset/e2f6a65a50a7/

Log:	OperationError -> oefmt in memoryobject.py

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
@@ -5,7 +5,7 @@
 
 from rpython.rlib.buffer import Buffer, SubBuffer
 from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import interp2app
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
 
@@ -83,7 +83,7 @@
     def descr_getitem(self, space, w_index):
         start, stop, step = space.decode_index(w_index, self.getlength())
         if step not in (0, 1):
-            raise OperationError(space.w_NotImplementedError, space.wrap(""))
+            raise oefmt(space.w_NotImplementedError, "")
         if step == 0:  # index only
             return space.wrap(self.buf.getitem(start))
         res = self.getslice(start, stop)
@@ -91,15 +91,14 @@
 
     def descr_setitem(self, space, w_index, w_obj):
         if self.buf.readonly:
-            raise OperationError(space.w_TypeError, space.wrap(
-                "cannot modify read-only memory"))
-        start, stop, step, size = space.decode_index4(w_index, self.buf.getlength())
+            raise oefmt(space.w_TypeError, "cannot modify read-only memory")
+        start, stop, step, size = space.decode_index4(w_index, self.getlength())
         if step not in (0, 1):
-            raise OperationError(space.w_NotImplementedError, space.wrap(""))
+            raise oefmt(space.w_NotImplementedError, "")
         value = space.buffer_w(w_obj, space.BUF_CONTIG_RO)
         if value.getlength() != size:
-            raise OperationError(space.w_ValueError, space.wrap(
-                "cannot modify size of memoryview object"))
+            raise oefmt(space.w_ValueError,
+                        "cannot modify size of memoryview object")
         if step == 0:  # index only
             self.buf.setitem(start, value.getitem(0))
         elif step == 1:


More information about the pypy-commit mailing list