Author: [email protected]
Branch: py3.6
Changeset: r91900:3ed5101a25c4
Date: 2017-07-16 14:46 +0200
http://bitbucket.org/pypy/pypy/changeset/3ed5101a25c4/

Log:    (ronan,pzieschang) fixed int() behaviour also for __trunc__
        returning a subclass of int

diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -865,7 +865,7 @@
             return _from_intlike(space, w_inttype, space.int(w_value))
         elif space.lookup(w_value, '__trunc__') is not None:
             w_obj = space.trunc(w_value)
-            if not space.isinstance_w(w_obj, space.w_int):
+            if not space.is_w(space.type(w_obj), space.w_int):
                 w_obj = space.int(w_obj)
             return _from_intlike(space, w_inttype, w_obj)
         elif space.isinstance_w(w_value, space.w_unicode):
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
@@ -337,7 +337,7 @@
                 return IntSubclass(42)
         n = int(TruncReturnsNonInt())
         assert n == 42
-        assert type(n) is IntSubclass
+        assert type(n) is int
 
     def test_long_before_string(self):
         class A(str):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to