Bue Krogh Vedel-Larsen wrote: > But if I call > > SA_PyVector_Type.tp_new = PyType_GenericNew; > PyType_Ready( &SA_PyVector_Type ); > > then, when Py_Finalize is called, PyObject_IS_GC(op) in visit_decref() in > gcmodule.c causes an access violation. If I don't call PyType_Ready, then > the access violation doesn't occure, but then the type can't be used... > > So, the question is, does anyone have any idea about what could be > causing this?
Most likely some code that you haven't shown. Here is the expansion of PyObject_IS_GC(op) #define PyObject_IS_GC(o) (PyType_IS_GC((o)->ob_type) && \ ((o)->ob_type->tp_is_gc == NULL || (o)->ob_type->tp_is_gc(o))) so it becomes PyType_IS_GC(op->type) && (op->ob_type->tp_is_gc==NULL || op->ob_type->tp_is_gc(op)) Then, PyType_IS_GC(op->type) becomes PyType_HasFeature((op->type), Py_TPFLAGS_HAVE_GC) which in turn becomes (op->tp_flags & Py_TPFLAGS_HAVE_GC) != 0 So typically, PyObject_IS_GC goes to the type of the object, which should never crash, and then looks into the flags of the type, which cannot crash - unless somebody messed with ob_type of the object, and unless this isn't a Python object in the first place. You did not say what kind of object op was in the crash - this is something you should investigate further. Does it point to a Python object? If so, what is the type of the Python object? Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list