[Python-Dev] New type objects and PyObject_New (original) (raw)

Thomas Heller thomas.heller@ion-tof.com
Tue, 9 Apr 2002 22:06:22 +0200


From: "Martin v. Loewis" <martin@v.loewis.de>

"Thomas Heller" <thomas.heller@ion-tof.com> writes:

> It seems possible to create new type objects still with > PyObjectNew() instead of calling the type object. > Is this a bug? Not sure what you are asking: I assume you are not asking about new type objects (as created by typeobject.c:typenew), but instead about instance of newstyle classes (i.e. instance of type objects). Correct. Why would you then think that using PyObjectNew is a bad thing?

IIUC, PyObject_New doesn't call the tp_new, tp_alloc, and tp_init slots. So, the new object probably will be in an invalid state, may be allocated by an allocator not compatible with the tp_dealloc slot?

Regards, Martin Thanks,

Thomas