(PyHeapTypeObject *)_PyObject_GC_Malloc(_PyObject_VAR_SIZE(metaty, 0));
if (!skel) skel = &emptytype;
memcpy(ty, skel, sizeof(*skel));
- if (ty->ht_type.tp_base) Py_INCREF(ty->ht_type.tp_base);
#define COPY(blah) do { \
if (ty->ht_type.tp_as_##blah) { \
memcpy(&ty->as_##blah, \
PyDict_SetItemString(ty->tp_dict, "__module__", modname);
}
-PyTypeObject *inittype(PyTypeObject *tyskel, PyTypeObject *meta)
+PyTypeObject *inittype(const PyTypeObject *tyskel,
+ PyTypeObject *base, PyTypeObject *meta)
{
PyTypeObject *ty = newtype(meta, tyskel, 0);
+ if (base) { ty->tp_base = base; Py_INCREF(base); }
ty->tp_flags |= Py_TPFLAGS_HEAPTYPE;
typeready(ty);
return (ty);
/*----- Populating modules ------------------------------------------------*/
PyObject *mkexc(PyObject *mod, PyObject *base,
- const char *name, PyMethodDef *mm)
+ const char *name, const PyMethodDef *mm)
{
PyObject *nameobj = 0;
PyObject *dict = 0;
if (mm) {
while (mm->ml_name) {
- if ((func = PyCFunction_NewEx(mm, 0, mod)) == 0 ||
+ if ((func = PyCFunction_NewEx((/*unconst*/ PyMethodDef *)mm,
+ 0, mod)) == 0 ||
(meth = PyMethod_New(func, 0, exc)) == 0 ||
PyDict_SetItemString(dict, mm->ml_name, meth))
goto fail;