[pypy-svn] r71604 - in pypy/trunk/pypy: doc objspace/std objspace/std/test
agaynor at codespeak.net
agaynor at codespeak.net
Tue Mar 2 04:50:50 CET 2010
Author: agaynor
Date: Tue Mar 2 04:50:41 2010
New Revision: 71604
Modified:
pypy/trunk/pypy/doc/objspace.txt
pypy/trunk/pypy/objspace/std/floatobject.py
pypy/trunk/pypy/objspace/std/intobject.py
pypy/trunk/pypy/objspace/std/longobject.py
pypy/trunk/pypy/objspace/std/multimethod.py
pypy/trunk/pypy/objspace/std/objspace.py
pypy/trunk/pypy/objspace/std/smallintobject.py
pypy/trunk/pypy/objspace/std/stdtypedef.py
pypy/trunk/pypy/objspace/std/test/test_intobject.py
Log:
#480. FailedToImplement is now split into FailedToImplement and FailedToImplementArgs which has w_type and w_value.
Modified: pypy/trunk/pypy/doc/objspace.txt
==============================================================================
--- pypy/trunk/pypy/doc/objspace.txt (original)
+++ pypy/trunk/pypy/doc/objspace.txt Tue Mar 2 04:50:41 2010
@@ -316,7 +316,7 @@
try:
z = ovfcheck(x + y)
except OverflowError:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer addition"))
return W_IntObject(space, z)
Modified: pypy/trunk/pypy/objspace/std/floatobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/floatobject.py (original)
+++ pypy/trunk/pypy/objspace/std/floatobject.py Tue Mar 2 04:50:41 2010
@@ -241,7 +241,7 @@
x = w_float1.floatval
y = w_float2.floatval
if y == 0.0:
- raise FailedToImplement(space.w_ZeroDivisionError, space.wrap("float division"))
+ raise FailedToImplementArgs(space.w_ZeroDivisionError, space.wrap("float division"))
return W_FloatObject(x / y)
truediv__Float_Float = div__Float_Float
@@ -254,7 +254,7 @@
x = w_float1.floatval
y = w_float2.floatval
if y == 0.0:
- raise FailedToImplement(space.w_ZeroDivisionError, space.wrap("float modulo"))
+ raise FailedToImplementArgs(space.w_ZeroDivisionError, space.wrap("float modulo"))
mod = math.fmod(x, y)
if (mod and ((y < 0.0) != (mod < 0.0))):
mod += y
@@ -265,7 +265,7 @@
x = w_float1.floatval
y = w_float2.floatval
if y == 0.0:
- raise FailedToImplement(space.w_ZeroDivisionError, space.wrap("float modulo"))
+ raise FailedToImplementArgs(space.w_ZeroDivisionError, space.wrap("float modulo"))
mod = math.fmod(x, y)
# fmod is typically exact, so vx-mod is *mathematically* an
# exact multiple of wx. But this is fp arithmetic, and fp
@@ -338,9 +338,9 @@
try:
z = math.pow(x,y)
except OverflowError:
- raise FailedToImplement(space.w_OverflowError, space.wrap("float power"))
+ raise FailedToImplementArgs(space.w_OverflowError, space.wrap("float power"))
except ValueError:
- raise FailedToImplement(space.w_ValueError, space.wrap("float power")) # xxx
+ raise FailedToImplementArgs(space.w_ValueError, space.wrap("float power")) # xxx
return W_FloatObject(z)
Modified: pypy/trunk/pypy/objspace/std/intobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/intobject.py (original)
+++ pypy/trunk/pypy/objspace/std/intobject.py Tue Mar 2 04:50:41 2010
@@ -86,7 +86,7 @@
try:
z = ovfcheck(x + y)
except OverflowError:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer addition"))
return wrapint(space, z)
@@ -96,7 +96,7 @@
try:
z = ovfcheck(x - y)
except OverflowError:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer substraction"))
return wrapint(space, z)
@@ -106,7 +106,7 @@
try:
z = ovfcheck(x * y)
except OverflowError:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer multiplication"))
return wrapint(space, z)
@@ -119,7 +119,7 @@
raise OperationError(space.w_ZeroDivisionError,
space.wrap("integer division by zero"))
except OverflowError:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer division"))
return wrapint(space, z)
div__Int_Int = floordiv__Int_Int
@@ -128,7 +128,7 @@
x = float(w_int1.intval)
y = float(w_int2.intval)
if y == 0.0:
- raise FailedToImplement(space.w_ZeroDivisionError, space.wrap("float division"))
+ raise FailedToImplementArgs(space.w_ZeroDivisionError, space.wrap("float division"))
return space.wrap(x / y)
def mod__Int_Int(space, w_int1, w_int2):
@@ -140,7 +140,7 @@
raise OperationError(space.w_ZeroDivisionError,
space.wrap("integer modulo by zero"))
except OverflowError:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer modulo"))
return wrapint(space, z)
@@ -153,7 +153,7 @@
raise OperationError(space.w_ZeroDivisionError,
space.wrap("integer divmod by zero"))
except OverflowError:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer modulo"))
# no overflow possible
m = x % y
@@ -169,7 +169,7 @@
space.wrap("pow() 2nd argument "
"cannot be negative when 3rd argument specified"))
## bounce it, since it always returns float
- raise FailedToImplement(space.w_ValueError,
+ raise FailedToImplementArgs(space.w_ValueError,
space.wrap("integer exponentiation"))
temp = iv
ix = 1
@@ -188,7 +188,7 @@
if iz:
ix = ix % iz
except OverflowError:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer exponentiation"))
return wrapint(space, ix)
@@ -211,7 +211,7 @@
try:
x = ovfcheck(-a)
except OverflowError:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer negation"))
return wrapint(space, x)
@@ -239,12 +239,12 @@
if a == 0 or b == 0:
return int__Int(space, w_int1)
if b >= LONG_BIT:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer left shift"))
try:
c = ovfcheck_lshift(a, b)
except OverflowError:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer left shift"))
return wrapint(space, c)
Modified: pypy/trunk/pypy/objspace/std/longobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/longobject.py (original)
+++ pypy/trunk/pypy/objspace/std/longobject.py Tue Mar 2 04:50:41 2010
@@ -195,7 +195,7 @@
def pow__Long_Long_None(space, w_long1, w_long2, w_long3):
# XXX need to replicate some of the logic, to get the errors right
if w_long2.num.lt(rbigint.fromint(0)):
- raise FailedToImplement(
+ raise FailedToImplementArgs(
space.w_ValueError,
space.wrap("long pow() too negative"))
return W_LongObject(w_long1.num.pow(w_long2.num, None))
Modified: pypy/trunk/pypy/objspace/std/multimethod.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/multimethod.py (original)
+++ pypy/trunk/pypy/objspace/std/multimethod.py Tue Mar 2 04:50:41 2010
@@ -25,6 +25,20 @@
class FailedToImplement(Exception):
+ def __init__(self, *args):
+ if args:
+ raise Exception
+
+ def get_w_value(self, space):
+ return None
+
+ def get_w_type(self, space):
+ return None
+
+ def __str__(self):
+ return '<FailedToImplement(None, None)>'
+
+class FailedToImplementArgs(FailedToImplement):
def __init__(self, w_type=None, w_value=None):
self.w_type = w_type
self.w_value = w_value
@@ -32,9 +46,13 @@
def get_w_value(self, space):
# convenience: same semantics as with OperationError
return self.w_value
+
+ def get_w_type(self, space):
+ return self.w_type
def __str__(self):
return '<FailedToImplement(%s, %s)>' % (self.w_type, self.w_value)
+
def raiseFailedToImplement():
Modified: pypy/trunk/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/objspace.py (original)
+++ pypy/trunk/pypy/objspace/std/objspace.py Tue Mar 2 04:50:41 2010
@@ -13,7 +13,7 @@
from pypy.tool.sourcetools import func_with_new_name
from pypy.objspace.std.model import W_Object, UnwrapError
from pypy.objspace.std.model import W_ANY, StdObjSpaceMultiMethod, StdTypeModel
-from pypy.objspace.std.multimethod import FailedToImplement
+from pypy.objspace.std.multimethod import FailedToImplement, FailedToImplementArgs
from pypy.objspace.descroperation import DescrOperation, raiseattrerror
from pypy.objspace.std import stdtypedef
from pypy.rlib.rarithmetic import base_int
Modified: pypy/trunk/pypy/objspace/std/smallintobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/smallintobject.py (original)
+++ pypy/trunk/pypy/objspace/std/smallintobject.py Tue Mar 2 04:50:41 2010
@@ -91,7 +91,7 @@
try:
z = ovfcheck(x * y)
except OverflowError:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer multiplication"))
return wrapint(space, z)
@@ -110,7 +110,7 @@
x = float(w_int1.intval)
y = float(w_int2.intval)
if y == 0.0:
- raise FailedToImplement(space.w_ZeroDivisionError, space.wrap("float division"))
+ raise FailedToImplementArgs(space.w_ZeroDivisionError, space.wrap("float division"))
return space.wrap(x / y)
def mod__SmallInt_SmallInt(space, w_int1, w_int2):
@@ -178,12 +178,12 @@
if a == 0 or b == 0:
return int__SmallInt(space, w_int1)
if b >= LONG_BIT:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer left shift"))
try:
c = ovfcheck_lshift(a, b)
except OverflowError:
- raise FailedToImplement(space.w_OverflowError,
+ raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer left shift"))
return wrapint(space, c)
Modified: pypy/trunk/pypy/objspace/std/stdtypedef.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/stdtypedef.py (original)
+++ pypy/trunk/pypy/objspace/std/stdtypedef.py Tue Mar 2 04:50:41 2010
@@ -219,7 +219,7 @@
try:
return %s
except FailedToImplement, e:
- if e.w_type is not None:
+ if e.get_w_type(space) is not None:
raise OperationError(e.w_type, e.get_w_value(space))
else:
return space.w_NotImplemented
@@ -231,7 +231,7 @@
try:
w_res = %s
except FailedToImplement, e:
- if e.w_type is not None:
+ if e.get_w_type(space) is not None:
raise OperationError(e.w_type, e.get_w_value(space))
else:
raise gettypeerror(space, %r, %s)
Modified: pypy/trunk/pypy/objspace/std/test/test_intobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/test/test_intobject.py (original)
+++ pypy/trunk/pypy/objspace/std/test/test_intobject.py Tue Mar 2 04:50:41 2010
@@ -25,7 +25,7 @@
res = func(*args, **kwds)
raise Exception, "should have failed but returned '%s'!" %repr(res)
except FailedToImplement, arg:
- return arg.w_type
+ return arg.get_w_type(self.space)
def test_int_w(self):
assert self.space.int_w(self.space.wrap(42)) == 42
More information about the Pypy-commit
mailing list