[pypy-commit] pypy py3k: adapt a2d8b4680ef9 to py3
pjenvey
pypy.commits at gmail.com
Sun Oct 9 22:31:06 EDT 2016
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r87683:9f40d9cc4ac8
Date: 2016-10-09 19:30 -0700
http://bitbucket.org/pypy/pypy/changeset/9f40d9cc4ac8/
Log: adapt a2d8b4680ef9 to py3
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
@@ -864,9 +864,12 @@
return w_value
return newbigint(space, w_inttype, space.bigint_w(w_value))
elif space.lookup(w_value, '__int__') is not None:
- return _from_intlike(space, w_inttype, w_value)
+ return _from_intlike(space, w_inttype, space.int(w_value))
elif space.lookup(w_value, '__trunc__') is not None:
- return _from_intlike(space, w_inttype, space.trunc(w_value))
+ w_obj = space.trunc(w_value)
+ if not space.isinstance_w(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):
from pypy.objspace.std.unicodeobject import unicode_to_decimal_w
b = unicode_to_decimal_w(space, w_value, allow_surrogates=True)
@@ -910,11 +913,10 @@
def _from_intlike(space, w_inttype, w_intlike):
- w_obj = space.int(w_intlike)
if space.is_w(w_inttype, space.w_int):
- return w_obj
+ return w_intlike
from pypy.objspace.std.longobject import newbigint
- return newbigint(space, w_inttype, space.bigint_w(w_obj))
+ return newbigint(space, w_inttype, space.bigint_w(w_intlike))
W_AbstractIntObject.typedef = TypeDef("int",
More information about the pypy-commit
mailing list