1. Tobias Pape
  2. pypy

Commits

Philip Jenvey  committed f42066b

operationerrfmt -> oefmt

  • Participants
  • Parent commits bf137ac
  • Branches py3k

Comments (0)

Files changed (15)

File pypy/interpreter/baseobjspace.py

View file
  • Ignore whitespace
                     raise
                 break  # done
             if idx == expected_length:
-                raise operationerrfmt(self.w_ValueError,
-                                      "too many values to unpack (expected %d)",
-                                      expected_length)
+                raise oefmt(self.w_ValueError,
+                            "too many values to unpack (expected %d)",
+                            expected_length)
             items[idx] = w_item
             idx += 1
         if idx < expected_length:

File pypy/interpreter/pyopcode.py

View file
  • Ignore whitespace
                 plural = ''
             else:
                 plural = 's'
-            raise operationerrfmt(self.space.w_ValueError,
-                                  "need more than %d value%s to unpack",
-                                  itemcount, plural)
+            raise oefmt(self.space.w_ValueError,
+                        "need more than %d value%s to unpack",
+                        itemcount, plural)
         right = itemcount - right
         assert right >= 0
         # push values in reverse order
         # fall-back
         w_value = self._load_global(w_varname)
         if w_value is None:
-            message = "name %R is not defined"
-            raise operationerrfmt(self.space.w_NameError, message, w_varname)
+            raise oefmt(self.space.w_NameError,
+                        "name %R is not defined", w_varname)
         self.pushvalue(w_value)
 
     def _load_global(self, w_varname):
         except OperationError as e:
             if not e.match(space, space.w_TypeError):
                 raise
-            raise operationerrfmt(space.w_TypeError,
-                                  "%s() arg 1 must be a %s object",
-                                  funcname, what)
+            raise oefmt(space.w_TypeError,
+                        "%s() arg 1 must be a %s object", funcname, what)
     return source, flags
 
 
     """Ensure globals/locals exist and are of the correct type"""
     if (not space.is_none(w_globals) and
         not space.isinstance_w(w_globals, space.w_dict)):
-        raise operationerrfmt(space.w_TypeError,
-                              '%s() arg 2 must be a dict, not %T',
-                              funcname, w_globals)
+        raise oefmt(space.w_TypeError,
+                    '%s() arg 2 must be a dict, not %T', funcname, w_globals)
     if (not space.is_none(w_locals) and
         space.lookup(w_locals, '__getitem__') is None):
-        raise operationerrfmt(space.w_TypeError,
-                              '%s() arg 3 must be a mapping or None, not %T',
-                              funcname, w_locals)
+        raise oefmt(space.w_TypeError,
+                    '%s() arg 3 must be a mapping or None, not %T',
+                    funcname, w_locals)
 
     if space.is_none(w_globals):
         if caller is None:

File pypy/interpreter/test/test_error.py

View file
  • Ignore whitespace
     expected = "illegal newline value: \"'PyLadies'\""
     assert operr._compute_value(space) == expected
 
-def test_operationerrfmt_unicode(space):
-    operr = operationerrfmt("w_type", "abc %s", u"àèìòù")
+def test_oefmt_unicode(space):
+    operr = oefmt("w_type", "abc %s", u"àèìòù")
     val = operr._compute_value(space)
     assert val == u"abc àèìòù"
 
-def test_operationerrfmt_utf8(space):
+def test_oefmt_utf8(space):
     arg = u"àèìòù".encode('utf-8')
-    operr = operationerrfmt("w_type", "abc %8", arg)
+    operr = oefmt("w_type", "abc %8", arg)
     val = operr._compute_value(space)
     assert val == u"abc àèìòù"
 

File pypy/module/__builtin__/functional.py

View file
  • Ignore whitespace
 """
 
 from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.typedef import TypeDef
 from rpython.rlib import jit
             return space.sequence_index(self, w_item)
 
         if not self._contains_long(space, w_item):
-            raise operationerrfmt(space.w_ValueError, "%R is not in range",
-                                  w_item)
+            raise oefmt(space.w_ValueError, "%R is not in range", w_item)
         w_index = space.sub(w_item, self.w_start)
         return space.floordiv(w_index, self.w_step)
 

File pypy/module/__builtin__/operation.py

View file
  • Ignore whitespace
 """
 
 from pypy.interpreter import gateway
-from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import unwrap_spec, WrappedDefault
 from rpython.rlib.runicode import UNICHR
 import __builtin__
 same type as the number. ndigits may be negative."""
     round = space.lookup(w_number, '__round__')
     if round is None:
-        raise operationerrfmt(space.w_TypeError,
-                              "type %T doesn't define __round__ method",
-                              w_number)
+        raise oefmt(space.w_TypeError,
+                    "type %T doesn't define __round__ method", w_number)
     if w_ndigits is None:
         return space.get_and_call_function(round, w_number)
     else:

File pypy/module/_codecs/interp_codecs.py

View file
  • Ignore whitespace
             raise OperationError(space.type(w_exc), w_exc)
         return space.newtuple([space.wrap(unichr(ch)), space.wrap(start + 3)])
     else:
-        raise operationerrfmt(space.w_TypeError,
-                              "don't know how to handle %T in error callback",
-                              w_exc)
+        raise oefmt(space.w_TypeError,
+                    "don't know how to handle %T in error callback", w_exc)
 
 def surrogateescape_errors(space, w_exc):
     check_exception(space, w_exc)
         return space.newtuple([space.wrap(replace),
                                space.wrap(start + consumed)])
     else:
-        raise operationerrfmt(space.w_TypeError,
-                              "don't know how to handle %T in error callback",
-                              w_exc)
+        raise oefmt(space.w_TypeError,
+                    "don't know how to handle %T in error callback", w_exc)
 
 def register_builtin_error_handlers(space):
     "NOT_RPYTHON"

File pypy/module/_io/interp_iobase.py

View file
  • Ignore whitespace
         return space.w_False
 
     def getstate_w(self, space):
-        raise operationerrfmt(space.w_TypeError,
-                              "cannot serialize '%T' object", self)
+        raise oefmt(space.w_TypeError, "cannot serialize '%T' object", self)
 
     # ______________________________________________________________
 

File pypy/module/_pypyjson/interp_decoder.py

View file
  • Ignore whitespace
 
 def loads(space, w_s):
     if space.isinstance_w(w_s, space.w_bytes):
-        raise operationerrfmt(space.w_TypeError,
-                              "Expected string, got %T", w_s)
+        raise oefmt(space.w_TypeError, "Expected string, got %T", w_s)
     s = space.str_w(w_s)
     decoder = JSONDecoder(space, s)
     try:

File pypy/module/_ssl/interp_ssl.py

View file
  • Ignore whitespace
 from __future__ import with_statement
 from rpython.rtyper.lltypesystem import rffi, lltype
-from pypy.interpreter.error import (
-    OperationError, operationerrfmt, wrap_oserror)
+from pypy.interpreter.error import OperationError, oefmt, wrap_oserror
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
 from pypy.interpreter.gateway import interp2app, unwrap_spec
         elif protocol == PY_SSL_VERSION_SSL23:
             method = libssl_SSLv23_method()
         else:
-            raise operationerrfmt(space.w_ValueError,
-                                  "invalid protocol version")
+            raise oefmt(space.w_ValueError, "invalid protocol version")
         self.ctx = libssl_SSL_CTX_new(method)
 
         # Defaults

File pypy/module/imp/interp_imp.py

View file
  • Ignore whitespace
     does not conform to PEP 3147 format, ValueError will be raised."""
     sourcename = importing.make_source_pathname(pathname)
     if sourcename is None:
-        raise operationerrfmt(space.w_ValueError,
-                              "Not a PEP 3147 pyc path: %s", pathname)
+        raise oefmt(space.w_ValueError,
+                    "Not a PEP 3147 pyc path: %s", pathname)
     return space.fsdecode(space.wrapbytes(sourcename))

File pypy/objspace/descroperation.py

View file
  • Ignore whitespace
         w_restype = space.type(w_res)
         # Note there is no check for bool here because the only possible
         # instances of bool are w_False and w_True, which are checked above.
-        raise operationerrfmt(space.w_TypeError,
-                              "__bool__ should return bool, returned %T",
-                              w_obj)
+        raise oefmt(space.w_TypeError,
+                    "__bool__ should return bool, returned %T", w_obj)
 
     def nonzero(space, w_obj):
         if space.is_true(w_obj):
     def buffer(space, w_obj):
         w_impl = space.lookup(w_obj, '__buffer__')
         if w_impl is None:
-            raise operationerrfmt(space.w_TypeError,
-                                  "'%T' does not support the buffer interface",
-                                  w_obj)
+            raise oefmt(space.w_TypeError,
+                        "'%T' does not support the buffer interface", w_obj)
         return space.get_and_call_function(w_impl, w_obj)
 
 
             return space.not_(space.eq(w_obj1, w_obj2))
         #
         # if we arrived here, they are unorderable
-        raise operationerrfmt(space.w_TypeError, "unorderable types: %T %s %T",
-                              w_obj1, symbol, w_obj2)
+        raise oefmt(space.w_TypeError,
+                    "unorderable types: %T %s %T", w_obj1, symbol, w_obj2)
 
     return func_with_new_name(comparison_impl, 'comparison_%s_impl'%left.strip('_'))
 

File pypy/objspace/std/bytesobject.py

View file
  • Ignore whitespace
         Example: bytes.fromhex('B9 01EF') -> b'\xb9\x01\xef'.
         """
         if not space.is_w(space.type(w_hexstring), space.w_unicode):
-            raise operationerrfmt(space.w_TypeError, "must be str, not %T",
-                                  w_hexstring)
+            raise oefmt(space.w_TypeError, "must be str, not %T", w_hexstring)
         from pypy.objspace.std.bytearrayobject import _hexstring_to_array
         hexstring = space.unicode_w(w_hexstring)
         bytes = ''.join(_hexstring_to_array(space, hexstring))
                 else:
                     raise
             if not 0 <= char < 256:
-                raise operationerrfmt(space.w_ValueError,
-                                      "character must be in range(256)")
+                raise oefmt(space.w_ValueError,
+                            "character must be in range(256)")
             return space.newbool(self._value.find(chr(char)) >= 0)
         return self._StringMethods_descr_contains(space, w_sub)
 
     if w_bytes_method is not None:
         w_bytes = space.get_and_call_function(w_bytes_method, w_source)
         if not space.isinstance_w(w_bytes, space.w_bytes):
-            msg = "__bytes__ returned non-bytes (type '%T')"
-            raise operationerrfmt(space.w_TypeError, msg, w_bytes)
+            raise oefmt(space.w_TypeError,
+                        "__bytes__ returned non-bytes (type '%T')", w_bytes)
         return [c for c in space.bytes_w(w_bytes)]
 
     # String-like argument

File pypy/objspace/std/objspace.py

View file
  • Ignore whitespace
 
     def _wrap_expected_length(self, expected, got):
         if got > expected:
-            raise operationerrfmt(self.w_ValueError,
-                                  "too many values to unpack (expected %d)",
-                                  expected)
+            raise oefmt(self.w_ValueError,
+                        "too many values to unpack (expected %d)", expected)
         else:
-            raise operationerrfmt(self.w_ValueError,
-                                  "need more than %d value%s to unpack",
-                                  got, got != 1 and "s" or "")
+            raise oefmt(self.w_ValueError,
+                        "need more than %d value%s to unpack",
+                        got, "" if got == 1 else "s")
 
     def unpackiterable(self, w_obj, expected_length=-1):
         if isinstance(w_obj, W_AbstractTupleObject) and self._uses_tuple_iter(w_obj):

File pypy/objspace/std/stringmethods.py

View file
  • Ignore whitespace
         list_to = makebytesdata_w(space, w_to)
 
         if len(list_from) != len(list_to):
-            raise operationerrfmt(space.w_ValueError,
-                                  "maketrans arguments must have same length")
+            raise oefmt(space.w_ValueError,
+                        "maketrans arguments must have same length")
 
         for i in range(len(list_from)):
             pos_from = ord(list_from[i])
             if not e.match(space, space.w_TypeError):
                 raise
             wanted = self._generic_name()
-            raise operationerrfmt(space.w_TypeError,
-                                  "startswith first arg must be %s or a tuple "
-                                  "of %s, not %T", wanted, wanted, w_prefix)
+            raise oefmt(space.w_TypeError,
+                        "startswith first arg must be %s or a tuple of %s, "
+                        "not %T", wanted, wanted, w_prefix)
         return space.newbool(res)
 
     def _startswith(self, space, value, w_prefix, start, end):
             if not e.match(space, space.w_TypeError):
                 raise
             wanted = self._generic_name()
-            raise operationerrfmt(space.w_TypeError,
-                                  "endswith first arg must be %s or a tuple "
-                                  "of %s, not %T", wanted, wanted, w_suffix)
+            raise oefmt(space.w_TypeError,
+                        "endswith first arg must be %s or a tuple of %s, not "
+                        "%T", wanted, wanted, w_suffix)
         return space.newbool(res)
 
     def _endswith(self, space, value, w_prefix, start, end):

File pypy/objspace/std/unicodeobject.py

View file
  • Ignore whitespace
     def _op_val(self, space, w_other):
         if isinstance(w_other, W_UnicodeObject):
             return w_other._value
-        raise operationerrfmt(space.w_TypeError,
-                              "Can't convert '%T' object to str implicitly",
-                              w_other)
+        raise oefmt(space.w_TypeError,
+                    "Can't convert '%T' object to str implicitly", w_other)
 
     def _chr(self, char):
         assert len(char) == 1