[ python-Bugs-1498638 ] tp_alloc for subtypes of PyComplex_Type is not called

SourceForge.net noreply at sourceforge.net
Thu Jun 1 10:27:51 CEST 2006


Bugs item #1498638, was opened at 2006-06-01 04:24
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1498638&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Travis Oliphant (teoliphant)
Assigned to: Nobody/Anonymous (nobody)
Summary: tp_alloc for subtypes of  PyComplex_Type is not called

Initial Comment:
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. 



----------------------------------------------------------------------

>Comment By: Georg Brandl (gbrandl)
Date: 2006-06-01 08:27

Message:
Logged In: YES 
user_id=849994

Fixed in rev. 46586.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1498638&group_id=5470


More information about the Python-bugs-list mailing list