[pypy-commit] pypy py3k: operationerrfmt -> oefmt
pjenvey
noreply at buildbot.pypy.org
Mon Feb 3 23:52:03 CET 2014
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r69065:f42066bae86d
Date: 2014-02-03 14:49 -0800
http://bitbucket.org/pypy/pypy/changeset/f42066bae86d/
Log: operationerrfmt -> oefmt
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -838,9 +838,9 @@
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:
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -787,9 +787,9 @@
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
@@ -835,8 +835,8 @@
# 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):
@@ -1560,9 +1560,8 @@
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
@@ -1570,14 +1569,13 @@
"""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:
diff --git a/pypy/interpreter/test/test_error.py b/pypy/interpreter/test/test_error.py
--- a/pypy/interpreter/test/test_error.py
+++ b/pypy/interpreter/test/test_error.py
@@ -82,14 +82,14 @@
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 àèìòù"
diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py
--- a/pypy/module/__builtin__/functional.py
+++ b/pypy/module/__builtin__/functional.py
@@ -4,7 +4,7 @@
"""
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
@@ -442,8 +442,7 @@
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)
diff --git a/pypy/module/__builtin__/operation.py b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -3,7 +3,7 @@
"""
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__
@@ -105,9 +105,8 @@
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:
diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -329,9 +329,8 @@
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)
@@ -369,9 +368,8 @@
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"
diff --git a/pypy/module/_io/interp_iobase.py b/pypy/module/_io/interp_iobase.py
--- a/pypy/module/_io/interp_iobase.py
+++ b/pypy/module/_io/interp_iobase.py
@@ -172,8 +172,7 @@
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)
# ______________________________________________________________
diff --git a/pypy/module/_pypyjson/interp_decoder.py b/pypy/module/_pypyjson/interp_decoder.py
--- a/pypy/module/_pypyjson/interp_decoder.py
+++ b/pypy/module/_pypyjson/interp_decoder.py
@@ -388,8 +388,7 @@
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:
diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
--- a/pypy/module/_ssl/interp_ssl.py
+++ b/pypy/module/_ssl/interp_ssl.py
@@ -1,7 +1,6 @@
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
@@ -102,8 +101,7 @@
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
diff --git a/pypy/module/imp/interp_imp.py b/pypy/module/imp/interp_imp.py
--- a/pypy/module/imp/interp_imp.py
+++ b/pypy/module/imp/interp_imp.py
@@ -237,6 +237,6 @@
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))
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -251,9 +251,8 @@
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):
@@ -477,9 +476,8 @@
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)
@@ -598,8 +596,8 @@
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('_'))
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -502,8 +502,7 @@
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))
@@ -614,8 +613,8 @@
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)
@@ -726,8 +725,8 @@
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
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -404,13 +404,12 @@
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):
diff --git a/pypy/objspace/std/stringmethods.py b/pypy/objspace/std/stringmethods.py
--- a/pypy/objspace/std/stringmethods.py
+++ b/pypy/objspace/std/stringmethods.py
@@ -44,8 +44,8 @@
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])
@@ -510,9 +510,9 @@
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):
@@ -532,9 +532,9 @@
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):
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -99,9 +99,8 @@
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
More information about the pypy-commit
mailing list