[pypy-commit] pypy py3.6: Merged in mad-marty/pypy/py3.6 (pull request #556)
rlamy
pypy.commits at gmail.com
Sun Jul 16 08:24:01 EDT 2017
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.6
Changeset: r91896:f593f803fcdb
Date: 2017-07-16 12:23 +0000
http://bitbucket.org/pypy/pypy/changeset/f593f803fcdb/
Log: Merged in mad-marty/pypy/py3.6 (pull request #556)
(ronan,pzieschang) fixed int() behaviour to mirror python 3.6, where
a real int must be returned
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -277,6 +277,7 @@
"expected %s, got %T object", expected, self)
def int(self, space):
+ from pypy.objspace.std.intobject import _new_int
w_impl = space.lookup(self, '__int__')
if w_impl is None:
self._typed_unwrap_error(space, "integer")
@@ -291,6 +292,8 @@
"The ability to return an instance of a strict subclass of int "
"is deprecated, and may be removed in a future version of "
"Python." % (tp,)), space.w_DeprecationWarning)
+ # convert to int to be like python 3.6
+ w_result = _new_int(space, space.w_int, w_result)
return w_result
raise oefmt(space.w_TypeError,
"__int__ returned non-int (type '%T')", w_result)
diff --git a/pypy/objspace/std/test/test_longobject.py b/pypy/objspace/std/test/test_longobject.py
--- a/pypy/objspace/std/test/test_longobject.py
+++ b/pypy/objspace/std/test/test_longobject.py
@@ -315,7 +315,8 @@
return IntSubclass(42)
n = int(ReturnsIntSubclass())
assert n == 42
- assert type(n) is IntSubclass
+ # cpython 3.6 fixed behaviour to actually return type int here
+ assert type(n) is int
def test_trunc_returns(self):
# but!: (blame CPython 2.7)
More information about the pypy-commit
mailing list