![](https://secure.gravatar.com/avatar/12362ecee4672f1dd2d641ce5b4eca14.jpg?s=120&d=mm&r=g)
Thomas Heller wrote:
I'm trying to port Don Beaudry's objectmodule to Python 2.0 and encountered the following problem. Here is a part from Don's code:
co = (MetaClassObject*) PyClass_New(NULL, methods, name); co = PyObject_Realloc(co, sizeof (MetaClassObject));
As you see, he is trying to achive cheap code reuse. This code does not work.
I have tracked it down to the following sample, which does also not work. In the debug version on windows, the PyObject_REALLOC fails with an assertion-error: _CrtIsValidHeapPointer(pUserData)
op = PyObject_NEW(PyClassObject, &PyClass_Type); op = PyObject_REALLOC(op, sizeof(PyClassObject) + 20);
Should the above work or am I doing something wrong?
Wouldn't it be safer to first create a MetaClassObject and then let the standard ClassObject initialize it ? -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/