X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/3ed16ce3e1b50da2a4b18637d40775a52b3a2c74..ddd4720bd8a7e04bb37ba6825b46f1bbdce9d3e7:/pyke/pyke.c diff --git a/pyke/pyke.c b/pyke/pyke.c index b462a1f..f19c9e4 100644 --- a/pyke/pyke.c +++ b/pyke/pyke.c @@ -218,7 +218,6 @@ void *newtype(PyTypeObject *metaty, (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, \ @@ -249,9 +248,11 @@ void typeready(PyTypeObject *ty) 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);