[Python-Dev] Py_TPFLAGS_HEAPTYPE too overloaded

2009-07-26 Thread Joshua Haberman
I'm writing a C Python extension that needs to generate PyTypeObjects dynamically. Unfortunately, the Py_TPFLAGS_HEAPTYPE flag is overloaded in a way that makes it difficult to achieve this goal. The documentation for Pt_TPFLAGS_HEAPTYPE says: Py_TPFLAGS_HEAPTYPE This bit is set when the type

Re: [Python-Dev] Py_TPFLAGS_HEAPTYPE too overloaded

2009-07-27 Thread Joshua Haberman
Greg Ewing canterbury.ac.nz> writes: > Joshua Haberman wrote: > > This is not as bad as having someone > > set __class__ on one of my instances, or set attributes on my type, etc. > > Is there any real need to prevent someone from doing > those things? My ultimate

[Python-Dev] another Py_TPFLAGS_HEAPTYPE question

2009-08-16 Thread Joshua Haberman
I wrote to this list a few weeks ago asking about Py_TPFLAGS_HEAPTYPE (http://thread.gmane.org/gmane.comp.python.devel/105648). It occurred to me today that I could probably make object instances INCREF and DECREF my type appropriately, without setting Py_TPFLAGS_HEAPTYPE, by writing my own tp_all

Re: [Python-Dev] another Py_TPFLAGS_HEAPTYPE question

2009-08-16 Thread Joshua Haberman
On Sun, Aug 16, 2009 at 3:37 PM, "Martin v. Löwis" wrote: >> So where does the Py_DECREF() for the above Py_INCREF() live?  I >> expected to find this code snippet somewhere, but couldn't: >> >>   if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) >>     Py_DECREF(type); > > For a regular heaptype, it's in

Re: [Python-Dev] another Py_TPFLAGS_HEAPTYPE question

2009-08-17 Thread Joshua Haberman
On Sun, Aug 16, 2009 at 11:53 PM, "Martin v. Löwis" wrote: >> Thanks for the pointer.  I noticed that subtype_dealloc is only called for >> types >> that are allocated using type_new().  Does this mean that it is not >> safe to create >> types in C using just PyType_Ready() and set Py_TPFLAGS_HEAP

Re: [Python-Dev] another Py_TPFLAGS_HEAPTYPE question

2009-08-17 Thread Joshua Haberman
On Mon, Aug 17, 2009 at 1:41 PM, "Martin v. Löwis" wrote: >>> As Benjamin says, this is getting off-topic - python-dev is not a place >>> to ask for help in your project. >> >> Please let me know where is a more suitable place to discuss the >> implementation of the cPython as it pertains to C exte