[Python-bugs-list] bug in complex_nonzero (PR#347)
fvdp@decis.be
fvdp@decis.be
Mon, 5 Jun 2000 13:12:36 -0400 (EDT)
Full_Name: Frédéric van der Plancke
Version: 1.5.1
OS: Windows NT 4
Submission from: i0913.bfp-s.euronet.be (212.65.51.151)
There is a bug in the test for non-nullity of a complex number.
e.g. not (1j), not (4+0j) both return 1.
(they should return 0, like (not n) for any non-null number n.)
correction in <complexobject.c>:
'||' instead of '&&' in complex_nonzero(v):
static int
complex_nonzero(v)
PyComplexObject *v;
{
return v->cval.real != 0.0 || v->cval.imag != 0.0;
}
(Warning: I did not test my correction ;-)
LEGALESE:
I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under
copyright, patent or other rights or interests ("claims"). To
the extent that I have any such claims, I hereby grant to CNRI a
nonexclusive, irrevocable, royalty-free, worldwide license to
reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part
of the Python software and its related documentation, or any
derivative versions thereof, at no cost to CNRI or its licensed
users, and to authorize others to do so.
I acknowledge that CNRI may, at its sole discretion, decide
whether or not to incorporate this contribution in the Python
software and its related documentation. I further grant CNRI
permission to use my name and other identifying information
provided to CNRI by me for use in connection with the Python
software and its related documentation.