Possible incoherences on Py_TPFLAGS_HEAPTYPE.

B

Boris Boutillier

I don't know if this is the right place to ask my question, but if needed
I'll post it on the python-dev mailing list.

I'm writing a C-extension module for python 2.3.
I need to declare a new class, MyClass.
For this class I want two things :
1) redefine the setattr function on objects of this class
(ie setting a new tp_setattro)
2) I want that the python user can change attributes on MyClass (the
class itself).

Now I have a conflict on the Py_TPFLAGS_HEAPTYPE with new Python 2.3.
If I have Py_TPFLAGS_HEAPTYPE set on MyClass, I'll have problem with the
new hackcheck (Object/typeobject.c:3631), as I am a HEAPTYPE but I also
redefine tp_setattro.
If I don't have Py_TPFLAGS_HEAPTYPE, the user can't set new attributes on
my class because of a check in type_setattro (Object/typeobject.c:2047).

Have I missed something ?

Boris
 
M

Michael Hudson

Boris Boutillier said:
I don't know if this is the right place to ask my question, but if needed
I'll post it on the python-dev mailing list.

I'm writing a C-extension module for python 2.3.
I need to declare a new class, MyClass.
For this class I want two things :
1) redefine the setattr function on objects of this class
(ie setting a new tp_setattro)
2) I want that the python user can change attributes on MyClass (the
class itself).

Now I have a conflict on the Py_TPFLAGS_HEAPTYPE with new Python 2.3.
If I have Py_TPFLAGS_HEAPTYPE set on MyClass, I'll have problem with the
new hackcheck (Object/typeobject.c:3631), as I am a HEAPTYPE but I also
redefine tp_setattro.
If I don't have Py_TPFLAGS_HEAPTYPE, the user can't set new attributes on
my class because of a check in type_setattro (Object/typeobject.c:2047).

Have I missed something ?

Not sure. You might want to consider a custom metaclass, but I
understand they're painful in C (and I'm not even sure that would
solve the problem).

Cheers,
mwh

--
> Touche! But this confirms you are composed of logic gates.
Crud, I thought those were neurons in there.
-- Thomas F. Burdick, Kenny Tilton, comp.lang.lisp
 
B

Boris Boutillier

Do you think this question should be sent to Python-Dev ?
I am subscribed to the Python-Dev mailing list but never posted on it.

Boris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,458
Latest member
Chris#

Latest Threads

Top