Author: Antonio Cuni <[email protected]>
Branch: fastjson
Changeset: r65066:6f79e542d94b
Date: 2013-06-28 15:34 +0200
http://bitbucket.org/pypy/pypy/changeset/6f79e542d94b/
Log: don't crash in this case
diff --git a/pypy/module/_fastjson/interp_decoder.py
b/pypy/module/_fastjson/interp_decoder.py
--- a/pypy/module/_fastjson/interp_decoder.py
+++ b/pypy/module/_fastjson/interp_decoder.py
@@ -2,6 +2,7 @@
import math
from rpython.rlib.rstring import StringBuilder
from rpython.rlib.objectmodel import specialize
+from rpython.rlib import rfloat
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.gateway import unwrap_spec
from pypy.interpreter import unicodehelper
@@ -157,7 +158,10 @@
# build the float
floatval = intval + frcval
if exp != 0:
- floatval = floatval * math.pow(10, exp)
+ try:
+ floatval = floatval * math.pow(10, exp)
+ except OverflowError:
+ floatval = rfloat.INFINITY
return self.space.wrap(floatval)
else:
return self.space.wrap(intval)
diff --git a/pypy/module/_fastjson/test/test__fastjson.py
b/pypy/module/_fastjson/test/test__fastjson.py
--- a/pypy/module/_fastjson/test/test__fastjson.py
+++ b/pypy/module/_fastjson/test/test__fastjson.py
@@ -126,6 +126,8 @@
check(x, float(x))
x = str(sys.maxint+1) + 'E1'
check(x, float(x))
+ #
+ check('1E400', float('inf'))
def test_decode_numeric_invalid(self):
import _fastjson
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit