Message163552
You're right, I was confusing what happens automatically for classes defined in Python (i.e. the full treatment in type_new) vs those defined statically (i.e. just the parts in PyType_Ready).
Given that PyType_FromSpec doesn't currently support inheritance, providing a default tp_dealloc before the inherit_slots() call in PyType_Ready would work OK in the near term.
However, once inheritance support is added by #15146 then it would be wrong - the default slot entry would override an inherited one.
So, I think this adjustment actually needs to be handled in PyType_Ready, at some point after the inherit_slots() call.
Something like:
/* Sanity check for tp_dealloc. */
if ((type->tp_flags & Py_TPFLAGS_HEAPTYPE) &&
(type->tp_dealloc == type_dealloc)) {
/* Type has been declared as a heap type, but has inherited the
default allocator. This can happen when using the limited API
to dynamically create types.
*/
type->tp_dealloc = subtype_dealloc;
} |
|
Date |
User |
Action |
Args |
2012-06-23 08:42:37 | ncoghlan | set | recipients:
+ ncoghlan, loewis, pitrou, daniel.urban, Robin.Schreiber |
2012-06-23 08:42:37 | ncoghlan | set | messageid: <1340440957.09.0.552325699632.issue15142@psf.upfronthosting.co.za> |
2012-06-23 08:42:36 | ncoghlan | link | issue15142 messages |
2012-06-23 08:42:34 | ncoghlan | create | |
|