Author: Antonio Cuni <[email protected]>
Branch: fastjson
Changeset: r65053:bd082881bde9
Date: 2013-06-28 12:06 +0200
http://bitbucket.org/pypy/pypy/changeset/bd082881bde9/
Log: handle also the exponent
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
@@ -170,14 +170,23 @@
# skip the integral part
while self.ll_chars[i].isdigit():
i += 1
+ #
+ # skip the fractional part, if any
if self.ll_chars[i] == '.':
is_float = True
i += 1
- # skip the fractional part
while self.ll_chars[i].isdigit():
i += 1
+ #
+ # skip the exponent part, if any
+ if self.ll_chars[i] == 'e' or self.ll_chars[i] == 'E':
+ is_float = True
+ i += 1
+ while self.ll_chars[i].isdigit():
+ i += 1
+ #
+ self.pos = i
s = self.getslice(start, i)
- self.pos = i
if is_float:
w_func = self.space.w_float
else:
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
@@ -121,8 +121,11 @@
check('5E0001', 50.0)
check(str(1 << 32), 1 << 32)
check(str(1 << 64), 1 << 64)
+ #
x = str(sys.maxint+1) + '.123'
check(x, float(x))
+ x = str(sys.maxint+1) + 'E1'
+ check(x, float(x))
def test_decode_numeric_invalid(self):
import _fastjson
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit