X-Git-Url: https://git.distorted.org.uk/~mdw/pyke/blobdiff_plain/87fa2d560608d1b07c715357dc524e0d9eb3286c..4509276e7147042c753ec7180d1dd8e1f5923906:/pyke.c diff --git a/pyke.c b/pyke.c index b462a1f..29dd8c5 100644 --- a/pyke.c +++ b/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, \ @@ -238,6 +237,7 @@ void *newtype(PyTypeObject *metaty, ty->ht_name = PyString_FromString(ty->ht_type.tp_name); if (ty->ht_name) ty->ht_type.tp_name = PyString_AS_STRING(ty->ht_name); + ty->ht_slots = 0; (void)PyObject_INIT(&ty->ht_type, metaty); Py_INCREF(metaty); return (ty); @@ -249,9 +249,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);