[pypy-commit] pypy remove-intlong-smm: operationerrfmt -> oefmt
pjenvey
noreply at buildbot.pypy.org
Mon Feb 3 23:52:00 CET 2014
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: remove-intlong-smm
Changeset: r69063:3ebdf4080384
Date: 2014-02-03 14:47 -0800
http://bitbucket.org/pypy/pypy/changeset/3ebdf4080384/
Log: operationerrfmt -> oefmt
diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -20,7 +20,7 @@
from pypy.interpreter import typedef
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.buffer import Buffer
-from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import (
WrappedDefault, interp2app, interpindirect2app, unwrap_spec)
from pypy.objspace.std import newformat
@@ -161,8 +161,8 @@
elif isinstance(w_modulus, W_AbstractIntObject):
z = space.int_w(w_modulus)
if z == 0:
- raise operationerrfmt(space.w_ValueError,
- "pow() 3rd argument cannot be 0")
+ raise oefmt(space.w_ValueError,
+ "pow() 3rd argument cannot be 0")
else:
# can't return NotImplemented (space.pow doesn't do full
# ternary, i.e. w_modulus.__zpow__(self, w_exponent)), so
@@ -307,8 +307,7 @@
try:
z = ovfcheck(x // y)
except ZeroDivisionError:
- raise operationerrfmt(space.w_ZeroDivisionError,
- "integer division by zero")
+ raise oefmt(space.w_ZeroDivisionError, "integer division by zero")
return wrapint(space, z)
descr_floordiv, descr_rfloordiv = _make_descr_binop(_floordiv)
@@ -319,8 +318,7 @@
x = float(space.int_w(self))
y = float(space.int_w(w_other))
if y == 0.0:
- raise operationerrfmt(space.w_ZeroDivisionError,
- "division by zero")
+ raise oefmt(space.w_ZeroDivisionError, "division by zero")
return space.wrap(x / y)
descr_truediv, descr_rtruediv = _make_descr_binop(_truediv, ovf=False)
@@ -330,8 +328,7 @@
try:
z = ovfcheck(x % y)
except ZeroDivisionError:
- raise operationerrfmt(space.w_ZeroDivisionError,
- "integer modulo by zero")
+ raise oefmt(space.w_ZeroDivisionError, "integer modulo by zero")
return wrapint(space, z)
descr_mod, descr_rmod = _make_descr_binop(_mod)
@@ -341,8 +338,7 @@
try:
z = ovfcheck(x // y)
except ZeroDivisionError:
- raise operationerrfmt(space.w_ZeroDivisionError,
- "integer divmod by zero")
+ raise oefmt(space.w_ZeroDivisionError, "integer divmod by zero")
# no overflow possible
m = x % y
w = space.wrap
@@ -356,7 +352,7 @@
c = ovfcheck(a << b)
return wrapint(space, c)
if b < 0:
- raise operationerrfmt(space.w_ValueError, "negative shift count")
+ raise oefmt(space.w_ValueError, "negative shift count")
# b >= LONG_BIT
if a == 0:
return self.int(space)
@@ -368,8 +364,7 @@
b = space.int_w(w_other)
if r_uint(b) >= LONG_BIT: # not (0 <= b < LONG_BIT)
if b < 0:
- raise operationerrfmt(space.w_ValueError,
- "negative shift count")
+ raise oefmt(space.w_ValueError, "negative shift count")
# b >= LONG_BIT
if a == 0:
return self.int(space)
@@ -414,9 +409,8 @@
def uint_w(self, space):
intval = self.intval
if intval < 0:
- raise operationerrfmt(space.w_ValueError,
- "cannot convert negative integer to "
- "unsigned")
+ raise oefmt(space.w_ValueError,
+ "cannot convert negative integer to unsigned")
return r_uint(intval)
def bigint_w(self, space):
@@ -459,9 +453,9 @@
def _pow_impl(space, iv, iw, iz):
if iw < 0:
if iz != 0:
- raise operationerrfmt(space.w_TypeError,
- "pow() 2nd argument cannot be negative when "
- "3rd argument specified")
+ raise oefmt(space.w_TypeError,
+ "pow() 2nd argument cannot be negative when 3rd "
+ "argument specified")
# bounce it, since it always returns float
raise ValueError
temp = iv
@@ -572,9 +566,9 @@
except OperationError as e:
if not e.match(space, space.w_TypeError):
raise
- raise operationerrfmt(space.w_TypeError,
- "int() argument must be a string or a number, not '%T'",
- w_value)
+ raise oefmt(space.w_TypeError,
+ "int() argument must be a string or a number, "
+ "not '%T'", w_value)
else:
buf = space.interp_w(Buffer, w_buffer)
value, w_longval = _string_to_int_or_long(space, w_value,
@@ -590,16 +584,16 @@
try:
s = space.str_w(w_value)
except OperationError as e:
- raise operationerrfmt(space.w_TypeError,
- "int() can't convert non-string with "
- "explicit base")
+ raise oefmt(space.w_TypeError,
+ "int() can't convert non-string with explicit "
+ "base")
value, w_longval = _string_to_int_or_long(space, w_value, s, base)
if w_longval is not None:
if not space.is_w(w_inttype, space.w_int):
- raise operationerrfmt(space.w_OverflowError,
- "long int too large to convert to int")
+ raise oefmt(space.w_OverflowError,
+ "long int too large to convert to int")
return w_longval
elif space.is_w(w_inttype, space.w_int):
# common case
diff --git a/pypy/objspace/std/longobject.py b/pypy/objspace/std/longobject.py
--- a/pypy/objspace/std/longobject.py
+++ b/pypy/objspace/std/longobject.py
@@ -10,7 +10,7 @@
from pypy.interpreter import typedef
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.buffer import Buffer
-from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import (
WrappedDefault, interp2app, interpindirect2app, unwrap_spec)
from pypy.objspace.std import newformat
@@ -78,18 +78,17 @@
try:
return space.wrap(bigint.bit_length())
except OverflowError:
- raise operationerrfmt(space.w_OverflowError,
- "too many digits in integer")
+ raise oefmt(space.w_OverflowError, "too many digits in integer")
def _truediv(self, space, w_other):
try:
f = self.asbigint().truediv(w_other.asbigint())
except ZeroDivisionError:
- raise operationerrfmt(space.w_ZeroDivisionError,
- "long division or modulo by zero")
+ raise oefmt(space.w_ZeroDivisionError,
+ "long division or modulo by zero")
except OverflowError:
- raise operationerrfmt(space.w_OverflowError,
- "long/long too large for a float")
+ raise oefmt(space.w_OverflowError,
+ "long/long too large for a float")
return space.newfloat(f)
@delegate_other
@@ -226,8 +225,8 @@
try:
return self.num.tofloat()
except OverflowError:
- raise operationerrfmt(space.w_OverflowError,
- "long int too large to convert to float")
+ raise oefmt(space.w_OverflowError,
+ "long int too large to convert to float")
def toint(self):
return self.num.toint()
@@ -249,20 +248,18 @@
try:
return self.num.toint()
except OverflowError:
- raise operationerrfmt(space.w_OverflowError,
- "long int too large to convert to int")
+ raise oefmt(space.w_OverflowError,
+ "long int too large to convert to int")
def uint_w(self, space):
try:
return self.num.touint()
except ValueError:
- raise operationerrfmt(space.w_ValueError,
- "cannot convert negative integer to "
- "unsigned int")
+ raise oefmt(space.w_ValueError,
+ "cannot convert negative integer to unsigned int")
except OverflowError:
- raise operationerrfmt(space.w_OverflowError,
- "long int too large to convert to unsigned "
- "int")
+ raise oefmt(space.w_OverflowError,
+ "long int too large to convert to unsigned int")
def bigint_w(self, space):
return self.num
@@ -318,14 +315,13 @@
return space.w_NotImplemented
if w_exponent.asbigint().sign < 0:
- raise operationerrfmt(space.w_TypeError,
- "pow() 2nd argument cannot be negative when "
- "3rd argument specified")
+ raise oefmt(space.w_TypeError,
+ "pow() 2nd argument cannot be negative when 3rd "
+ "argument specified")
try:
result = self.num.pow(w_exponent.asbigint(), w_modulus.asbigint())
except ValueError:
- raise operationerrfmt(space.w_ValueError,
- "pow 3rd argument cannot be 0")
+ raise oefmt(space.w_ValueError, "pow 3rd argument cannot be 0")
return W_LongObject(result)
@unwrap_spec(w_modulus=WrappedDefault(None))
@@ -410,23 +406,21 @@
def _lshift(self, space, w_other):
if w_other.asbigint().sign < 0:
- raise operationerrfmt(space.w_ValueError, "negative shift count")
+ raise oefmt(space.w_ValueError, "negative shift count")
try:
shift = w_other.asbigint().toint()
except OverflowError: # b too big
- raise operationerrfmt(space.w_OverflowError,
- "shift count too large")
+ raise oefmt(space.w_OverflowError, "shift count too large")
return W_LongObject(self.num.lshift(shift))
descr_lshift, descr_rlshift = _make_descr_binop(_lshift)
def _rshift(self, space, w_other):
if w_other.asbigint().sign < 0:
- raise operationerrfmt(space.w_ValueError, "negative shift count")
+ raise oefmt(space.w_ValueError, "negative shift count")
try:
shift = w_other.asbigint().toint()
except OverflowError: # b too big # XXX maybe just return 0L instead?
- raise operationerrfmt(space.w_OverflowError,
- "shift count too large")
+ raise oefmt(space.w_OverflowError, "shift count too large")
return newlong(space, self.num.rshift(shift))
descr_rshift, descr_rrshift = _make_descr_binop(_rshift)
@@ -434,8 +428,8 @@
try:
z = self.num.floordiv(w_other.asbigint())
except ZeroDivisionError:
- raise operationerrfmt(space.w_ZeroDivisionError,
- "long division or modulo by zero")
+ raise oefmt(space.w_ZeroDivisionError,
+ "long division or modulo by zero")
return newlong(space, z)
descr_floordiv, descr_rfloordiv = _make_descr_binop(_floordiv)
@@ -446,8 +440,8 @@
try:
z = self.num.mod(w_other.asbigint())
except ZeroDivisionError:
- raise operationerrfmt(space.w_ZeroDivisionError,
- "long division or modulo by zero")
+ raise oefmt(space.w_ZeroDivisionError,
+ "long division or modulo by zero")
return newlong(space, z)
descr_mod, descr_rmod = _make_descr_binop(_mod)
@@ -455,8 +449,8 @@
try:
div, mod = self.num.divmod(w_other.asbigint())
except ZeroDivisionError:
- raise operationerrfmt(space.w_ZeroDivisionError,
- "long division or modulo by zero")
+ raise oefmt(space.w_ZeroDivisionError,
+ "long division or modulo by zero")
return space.newtuple([newlong(space, div), newlong(space, mod)])
descr_divmod, descr_rdivmod = _make_descr_binop(_divmod)
@@ -517,9 +511,9 @@
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
- raise operationerrfmt(space.w_TypeError,
- "long() argument must be a string or a number, not '%T'",
- w_value)
+ raise oefmt(space.w_TypeError,
+ "long() argument must be a string or a number, "
+ "not '%T'", w_value)
else:
buf = space.interp_w(Buffer, w_buffer)
return _string_to_w_long(space, w_longtype, w_value,
@@ -534,9 +528,9 @@
try:
s = space.str_w(w_value)
except OperationError:
- raise operationerrfmt(space.w_TypeError,
- "long() can't convert non-string with "
- "explicit base")
+ raise oefmt(space.w_TypeError,
+ "long() can't convert non-string with explicit "
+ "base")
return _string_to_w_long(space, w_longtype, w_value, s, base)
diff --git a/pypy/objspace/std/smalllongobject.py b/pypy/objspace/std/smalllongobject.py
--- a/pypy/objspace/std/smalllongobject.py
+++ b/pypy/objspace/std/smalllongobject.py
@@ -9,7 +9,7 @@
from rpython.rlib.rbigint import rbigint
from rpython.tool.sourcetools import func_renamer, func_with_new_name
-from pypy.interpreter.error import operationerrfmt
+from pypy.interpreter.error import oefmt
from pypy.interpreter.gateway import WrappedDefault, unwrap_spec
from pypy.objspace.std.intobject import W_AbstractIntObject
from pypy.objspace.std.longobject import W_AbstractLongObject, W_LongObject
@@ -49,20 +49,19 @@
b = intmask(a)
if b == a:
return b
- raise operationerrfmt(space.w_OverflowError,
- "long int too large to convert to int")
+ raise oefmt(space.w_OverflowError,
+ "long int too large to convert to int")
def uint_w(self, space):
a = self.longlong
if a < 0:
- raise operationerrfmt(space.w_ValueError,
- "cannot convert negative integer to "
- "unsigned int")
+ raise oefmt(space.w_ValueError,
+ "cannot convert negative integer to unsigned int")
b = r_uint(a)
if r_longlong(b) == a:
return b
- raise operationerrfmt(space.w_OverflowError,
- "long int too large to convert to unsigned int")
+ raise oefmt(space.w_OverflowError,
+ "long int too large to convert to unsigned int")
def bigint_w(self, space):
return self.asbigint()
@@ -133,8 +132,7 @@
z = w_modulus.longlong
if z == 0:
- raise operationerrfmt(space.w_ValueError,
- "pow() 3rd argument cannot be 0")
+ raise oefmt(space.w_ValueError, "pow() 3rd argument cannot be 0")
try:
return _pow_impl(space, self.longlong, w_exponent, z)
except ValueError:
@@ -260,8 +258,7 @@
raise OverflowError
z = x // y
except ZeroDivisionError:
- raise operationerrfmt(space.w_ZeroDivisionError,
- "integer division by zero")
+ raise oefmt(space.w_ZeroDivisionError, "integer division by zero")
return W_SmallLongObject(z)
descr_floordiv, descr_rfloordiv = _make_descr_binop(_floordiv)
@@ -276,8 +273,7 @@
raise OverflowError
z = x % y
except ZeroDivisionError:
- raise operationerrfmt(space.w_ZeroDivisionError,
- "integer modulo by zero")
+ raise oefmt(space.w_ZeroDivisionError, "integer modulo by zero")
return W_SmallLongObject(z)
descr_mod, descr_rmod = _make_descr_binop(_mod)
@@ -289,8 +285,7 @@
raise OverflowError
z = x // y
except ZeroDivisionError:
- raise operationerrfmt(space.w_ZeroDivisionError,
- "integer divmod by zero")
+ raise oefmt(space.w_ZeroDivisionError, "integer divmod by zero")
# no overflow possible
m = x % y
return space.newtuple([W_SmallLongObject(z), W_SmallLongObject(m)])
@@ -306,7 +301,7 @@
raise OverflowError
return W_SmallLongObject(c)
if b < 0:
- raise operationerrfmt(space.w_ValueError, "negative shift count")
+ raise oefmt(space.w_ValueError, "negative shift count")
# b >= LONGLONG_BIT
if a == 0:
return self
@@ -319,8 +314,7 @@
b = space.int_w(w_other)
if r_uint(b) >= LONGLONG_BIT: # not (0 <= b < LONGLONG_BIT)
if b < 0:
- raise operationerrfmt(space.w_ValueError,
- "negative shift count")
+ raise oefmt(space.w_ValueError, "negative shift count")
# b >= LONGLONG_BIT
if a == 0:
return self
@@ -398,9 +392,9 @@
iw = space.int_w(w_int2)
if iw < 0:
if iz != 0:
- raise operationerrfmt(space.w_TypeError,
- "pow() 2nd argument cannot be negative when "
- "3rd argument specified")
+ raise oefmt(space.w_TypeError,
+ "pow() 2nd argument cannot be negative when 3rd "
+ "argument specified")
raise ValueError
temp = iv
ix = r_longlong(1)
More information about the pypy-commit
mailing list