Author: Lars Wassermann <[email protected]>
Branch:
Changeset: r480:ee08c90d63b5
Date: 2013-06-26 14:54 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/ee08c90d63b5/
Log: added guards for float-primitives to return NaN and Infinity,
according to Smalltalk requirements when the math module raises the
according errors
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -319,8 +319,10 @@
@expose_primitive(FLOAT_SIN, unwrap_spec=[float])
def func(interp, s_frame, f):
- w_res = interp.space.wrap_float(math.sin(f))
- return w_res
+ try:
+ return interp.space.wrap_float(math.sin(f))
+ except ValueError:
+ return interp.space.wrap_float(rfloat.NAN)
@expose_primitive(FLOAT_ARCTAN, unwrap_spec=[float])
def func(interp, s_frame, f):
@@ -339,8 +341,10 @@
@expose_primitive(FLOAT_EXP, unwrap_spec=[float])
def func(interp, s_frame, f):
- w_res = interp.space.wrap_float(math.exp(f))
- return w_res
+ try:
+ return interp.space.wrap_float(math.exp(f))
+ except OverflowError:
+ return interp.space.wrap_float(rfloat.INFINITY)
MAKE_POINT = 18
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit