This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: tp_alloc for subtypes of PyComplex_Type is not called
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, teoliphant
Priority: normal Keywords:

Created on 2006-06-01 04:24 by teoliphant, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
complexbug.tgz teoliphant, 2006-06-01 04:24 Tar ball with a patch, a module and a test script
Messages (2)
msg28695 - (view) Author: Travis Oliphant (teoliphant) * (Python committer) Date: 2006-06-01 04:24
In the function complex_subtype_from_c_complex in the
file complexobject.c, the allocation routine for the
subtype is not called.   This causes memory management
problems if the sub-type does not use the Python memory
manager.  

The fix is to make the following change:

 {
        PyObject *op;

-       op = PyType_GenericAlloc(type, 0);
+       op = type->tp_alloc(type, 0);
        if (op != NULL)
                ((PyComplexObject *)op)->cval = cval;
        return op;


Attched is an example module and script illustrating
what can go wrong along with a patch. 

msg28696 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-06-01 08:27
Logged In: YES 
user_id=849994

Fixed in rev. 46586.
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43444
2006-06-01 04:24:13teoliphantcreate