[Python-Dev] return type of complex (original) (raw)
Antonio Cuni anto.cuni at gmail.com
Fri Oct 19 15:08:40 CEST 2012
- Previous message: [Python-Dev] Rejecting PEPs 407 and 413?
- Next message: [Python-Dev] return type of __complex__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
while fixing pypy to pass CPython 3.2 tests, I found what I think it's a inconsistency in how CPython (both 2.7 and 3.2) handles complex:
class Obj: ... def complex(self): ... return 2.0 ... obj = Obj() complex(obj) (2+0j)
import cmath cmath.acos(obj) Traceback (most recent call last): File "", line 1, in TypeError: complex should return a complex object
i.e., the complex constructor does not check that complex returns an actual complex, while the cmath functions do. To me it looks like a bug in complex_new which should do the check as well; however, there is a test in test_complex.test_constructor which checks that returning a float actually works.
Is that the real intended behavior?
ciao, Anto
- Previous message: [Python-Dev] Rejecting PEPs 407 and 413?
- Next message: [Python-Dev] return type of __complex__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]