Author: Carl Friedrich Bolz-Tereick <[email protected]>
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):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to