Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3.5 Changeset: r94257:4b1bc362c207 Date: 2018-04-06 01:00 +0100 http://bitbucket.org/pypy/pypy/changeset/4b1bc362c207/
Log: merge heads diff --git a/pypy/module/marshal/test/test_marshal.py b/pypy/module/marshal/test/test_marshal.py --- a/pypy/module/marshal/test/test_marshal.py +++ b/pypy/module/marshal/test/test_marshal.py @@ -229,7 +229,7 @@ BadReader(marshal.dumps(value))) -@pytest.mark.skipif('config.option.runappdirect') +@pytest.mark.skipif('config.option.runappdirect or sys.maxint > 2 ** 32') class AppTestSmallLong(AppTestMarshal): spaceconfig = AppTestMarshal.spaceconfig.copy() spaceconfig["objspace.std.withsmalllong"] = True diff --git a/pypy/module/marshal/test/test_marshalimpl.py b/pypy/module/marshal/test/test_marshalimpl.py --- a/pypy/module/marshal/test/test_marshalimpl.py +++ b/pypy/module/marshal/test/test_marshalimpl.py @@ -1,5 +1,6 @@ from pypy.module.marshal import interp_marshal from pypy.interpreter.error import OperationError +from pypy.objspace.std.intobject import W_IntObject import sys @@ -100,3 +101,15 @@ for i in range(100): _marshal_check(sign * ((1L << i) - 1L)) _marshal_check(sign * (1L << i)) + +def test_int_roundtrip(space): + a = 0xffffffff + w_a = space.newint(a) + m = interp_marshal.StringMarshaller(space, 4) + interp_marshal.marshal(space, w_a, m) + s = m.get_value() + u = interp_marshal.StringUnmarshaller(space, space.newbytes(s)) + w_res = u.load_w_obj() + + assert type(w_res) is W_IntObject + assert w_res.intval == w_a.intval == a diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py --- a/pypy/objspace/std/objspace.py +++ b/pypy/objspace/std/objspace.py @@ -312,7 +312,10 @@ return W_LongObject.fromrarith_int(val) def newlong_from_rbigint(self, val): - return newlong(self, val) + try: + return self.newint(val.toint()) + except OverflowError: + return newlong(self, val) def newtuple(self, list_w): from pypy.objspace.std.tupleobject import wraptuple _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit