[Python-bugs-list] [ python-Bugs-695651 ] complex_new does not always respect subtypes
SourceForge.net
noreply@sourceforge.net
Sat, 01 Mar 2003 09:27:52 -0800
Bugs item #695651, was opened at 2003-03-01 08:18
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=695651&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Greg Chapman (glchapman)
Assigned to: Nobody/Anonymous (nobody)
Summary: complex_new does not always respect subtypes
Initial Comment:
On comp.lang.python, David Mertz pointed out this:
>>> class ComplexSub(complex): pass
...
>>> c = ComplexSub(1+1j)
>>> type(c)
<type 'complex'>
In other words, trying to create a ComplexSub returns a
complex. The problem appears to be this check in
complex_new:
/* Special-case for single argumet that is already
complex */
if (PyComplex_CheckExact(r) && i == NULL) {
I believe the above should also check to see if the type
parameter is exactly complex:
/* Special-case for single argumet that is already
complex */
if (PyComplex_CheckExact(r) && i == NULL &&
PyComplex_CheckExact(type)) {
----------------------------------------------------------------------
>Comment By: Greg Chapman (glchapman)
Date: 2003-03-01 08:27
Message:
Logged In: YES
user_id=86307
Oops, obviously that check should be ;
if (PyComplex_CheckExact(r) && i == NULL &&
type == &PyComplex_Type) {
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=695651&group_id=5470