Message163552
| Author |
ncoghlan |
| Recipients |
Robin.Schreiber, daniel.urban, loewis, ncoghlan, pitrou |
| Date |
2012年06月23日.08:42:34 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1340440957.09.0.552325699632.issue15142@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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;
} |
|