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.

Author Vadim Pushtaev
Recipients Vadim Pushtaev, ncoghlan, ppperry, serhiy.storchaka
Date 2018-08-08.18:15:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1533752106.46.0.56676864532.issue34284@psf.upfronthosting.co.za>
In-reply-to
Content
Usually, tp_new==NULL means that __new__ is inherited, but not always. Here is the comment from typeobject.c:

/* The condition below could use some explanation.
   It appears that tp_new is not inherited for static types
   whose base class is 'object'; this seems to be a precaution
   so that old extension types don't suddenly become
   callable (object.__new__ wouldn't insure the invariants
   that the extension type's own factory function ensures).
   Heap types, of course, are under our control, so they do
   inherit tp_new; static extension types that specify some
   other built-in type as the default also
   inherit object.__new__. */


So my current solution is to explicitly set __new__ to the common helper function that raises TypeError in that case.

---

Thanks a lot for your comments and ideas. In truth, I feel a little overwhelmed and definitely need further guidance for this issue.
History
Date User Action Args
2018-08-08 18:15:06Vadim Pushtaevsetrecipients: + Vadim Pushtaev, ncoghlan, serhiy.storchaka, ppperry
2018-08-08 18:15:06Vadim Pushtaevsetmessageid: <1533752106.46.0.56676864532.issue34284@psf.upfronthosting.co.za>
2018-08-08 18:15:06Vadim Pushtaevlinkissue34284 messages
2018-08-08 18:15:06Vadim Pushtaevcreate