Message168579
As with every type, that has been created and initialized, HeapTypes created form PyType_FromSpecWithBases() have to pass through PyType_Ready(). Here the function inherit_special might be called, which, among other things, does the following:
....
3892 if (base != &PyBaseObject_Type ||
3893 (type->tp_flags & Py_TPFLAGS_HEAPTYPE)) {
3894 if (type->tp_new == NULL)
3895 type->tp_new = base->tp_new;
3896 }
....
The code does not know of Heaptypes that have been created from extension-types by the PEP 384 refactorings. This includes extension-types that do not specify a tp_new method but instead have seperate factory methods, that are only used within the extension module. inherit_special() might consequently assign inappropriate new-methods to these type objects.
To circumvent this issue, I propose to enhance PyType_FromSpecWithBases in the following way: If no tp_new has been specified, we assign the newly defined PySpec_New() method to tp_new which simply denies the user to create an instance of this type. This also prohibits inherit_special to falsely inherit inappropriate new-methods. |
|
Date |
User |
Action |
Args |
2012-08-19 15:57:46 | Robin.Schreiber | set | recipients:
+ Robin.Schreiber, loewis |
2012-08-19 15:57:46 | Robin.Schreiber | set | messageid: <1345391866.4.0.54341725267.issue15727@psf.upfronthosting.co.za> |
2012-08-19 15:57:45 | Robin.Schreiber | link | issue15727 messages |
2012-08-19 15:57:45 | Robin.Schreiber | create | |
|