Author: Romain Guillebert <[email protected]>
Branch: 
Changeset: r66164:ce1c1b2ad027
Date: 2013-08-15 19:07 +0200
http://bitbucket.org/pypy/pypy/changeset/ce1c1b2ad027/

Log:    Fix PyPy issue 1544

diff --git a/pypy/objspace/std/complextype.py b/pypy/objspace/std/complextype.py
--- a/pypy/objspace/std/complextype.py
+++ b/pypy/objspace/std/complextype.py
@@ -201,7 +201,7 @@
     if w_z is not None:
         # __complex__() must return a complex or (float,int,long) object
         # (XXX should not use isinstance here)
-        if not strict_typing and (space.isinstance_w(w_z, space.w_int) or 
+        if not strict_typing and (space.isinstance_w(w_z, space.w_int) or
                                   space.isinstance_w(w_z, space.w_long) or
                                   space.isinstance_w(w_z, space.w_float)):
             return (space.float_w(w_z), 0.0)
@@ -214,8 +214,10 @@
     #
     # no '__complex__' method, so we assume it is a float,
     # unless it is an instance of some subclass of complex.
-    if isinstance(w_complex, W_ComplexObject):
-        return (w_complex.realval, w_complex.imagval)
+    if space.is_true(space.isinstance(w_complex, 
space.gettypefor(W_ComplexObject))):
+        real = space.float(space.getattr(w_complex, space.wrap("real")))
+        imag = space.float(space.getattr(w_complex, space.wrap("imag")))
+        return (space.float_w(real), space.float_w(imag))
     #
     # Check that it is not a string (on which space.float() would succeed).
     if (space.isinstance_w(w_complex, space.w_str) or
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to