X-Git-Url: https://git.distorted.org.uk/~mdw/pyke/blobdiff_plain/8ca231751365b4d081eb22f58f652aa237d17a50..0156e4020eb3b13a1b9bcfa9887eb922ba5d9fa2:/util.c diff --git a/util.c b/util.c index c1d0ad8..8a0c06c 100644 --- a/util.c +++ b/util.c @@ -1,7 +1,5 @@ /* -*-c-*- * - * $Id$ - * * Miscellaneous utilities (not Catacomb-specific) * * (c) 2005 Straylight/Edgeware @@ -30,6 +28,10 @@ #include "catacomb-python.h" +/*----- External values ---------------------------------------------------*/ + +static PyObject *modname = 0; + /*----- Conversions -------------------------------------------------------*/ PyObject *getulong(unsigned long w) @@ -165,16 +167,22 @@ 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); - PyObject_INIT(&ty->ht_type, metaty); + DISCARD(PyObject_INIT(&ty->ht_type, metaty)); Py_INCREF(metaty); return (ty); } +void typeready(PyTypeObject *ty) +{ + PyType_Ready(ty); + PyDict_SetItemString(ty->tp_dict, "__module__", modname); +} + PyTypeObject *inittype(PyTypeObject *tyskel) { PyTypeObject *ty = newtype(&PyType_Type, tyskel, 0); ty->tp_flags |= Py_TPFLAGS_HEAPTYPE; - PyType_Ready(ty); + typeready(ty); return (ty); } @@ -636,6 +644,7 @@ PyMethodDef gmap_pymethods[] = { void util_pyinit(void) { + modname = PyString_FromString("catacomb"); INITTYPE(itemiter, root); INITTYPE(valiter, root); }