[pypy-commit] pypy py3.6: fix test_int_roundtrip in test_marshalimp.py
cfbolz
pypy.commits at gmail.com
Tue Feb 19 15:40:21 EST 2019
Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: py3.6
Changeset: r96102:c6cca0f534ca
Date: 2019-02-19 21:36 +0100
http://bitbucket.org/pypy/pypy/changeset/c6cca0f534ca/
Log: fix test_int_roundtrip in test_marshalimp.py
marshaling an int that doesn't fit into 32bit will now use the long
bytecode. it should still turn into an int on unmarshaling
diff --git a/pypy/objspace/std/marshal_impl.py b/pypy/objspace/std/marshal_impl.py
--- a/pypy/objspace/std/marshal_impl.py
+++ b/pypy/objspace/std/marshal_impl.py
@@ -210,7 +210,11 @@
raise oefmt(space.w_ValueError, "bad marshal data")
if negative:
result = result.neg()
- return space.newlong_from_rbigint(result)
+ # try to fit it into an int
+ try:
+ return space.newint(result.toint())
+ except OverflowError:
+ return space.newlong_from_rbigint(result)
def pack_float(f):
More information about the pypy-commit
mailing list