[Python-Dev] Possible bug in complexobject.c (still in Python 2.5) (original) (raw)

Guido van Rossum guido at python.org
Thu Jun 1 02:36:10 CEST 2006


I wouldn't be surprised if this is a genuine bug; the complex type doesn't get a lot of love from core developers.

Could you come up with a proposed fix, and a unit test showing that it works (and that the old version doesn't)? (Maybe a good unit test would require writing a custome C extension; in that case just show some sample code.)

--Guido

On 5/31/06, Travis E. Oliphant <oliphant.travis at ieee.org> wrote:

I'm curious about the difference between floatsubtypenew in floatobject.c complexsubtypefromccomplex in complexobject.c The former uses type->tpalloc(type, 0) to create memory for the object while the latter uses PyTypeGenericAlloc(type, 0) to create memory for the sub-type (thereby by-passing the sub-type's own memory allocator). It seems like this is a bug. Shouldn't type->tpalloc(type, 0) also be used in the case of allocating complex subtypes? This is causing problems in NumPy because we have a complex type that is a sub-type of the Python complex scalar. It sometimes uses the complexnew code to generate instances (so that the new interface is the same), but because complexsubtypefromccomplex is using PyTypeGenericAlloc this is causing errors. I can work around this by not calling the new method for the base type but this is not consistent.

Thanks for any feedback, -Travis


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org

-- --Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list