[New-bugs-announce] [issue29602] complex() on object with __complex__ function loses sign of zero imaginary part

Tom Krauss report at bugs.python.org
Sun Feb 19 19:49:52 EST 2017


New submission from Tom Krauss:

Consider the following simple class that provides a "__complex__" method.

class C(object):
  def __init__(self, x):
     self.x = x
  def __complex__(self):
    return self.x

x=C(-0j)

PYTHON 2.7.13
>>> x.x
-0j
>>> complex(x)
0j

PYTHON 3.6
>>> x.x
(-0-0j)
>>> complex(x)
(-0+0j)

----------
messages: 288177
nosy: Tom Krauss
priority: normal
severity: normal
status: open
title: complex() on object with __complex__ function loses sign of zero imaginary part
type: behavior
versions: Python 2.7, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29602>
_______________________________________


More information about the New-bugs-announce mailing list