From: Mark Wooding Date: Fri, 10 Apr 2015 14:19:25 +0000 (+0100) Subject: Stamp the module name onto types properly. X-Git-Url: https://git.distorted.org.uk/~mdw/pyke/commitdiff_plain/35ac67cc37668d5a0b1b46b18f93df5bb9b99272 Stamp the module name onto types properly. Our types are `dynamic', because the Python code adds extra methods to them. Apparently the correct thing to do in such cases is to put the raw type name in the `tp_name' slot, and stuff the module name into `tp_dict' by hand. --- diff --git a/util.c b/util.c index f56c7fd..717c3d9 100644 --- a/util.c +++ b/util.c @@ -170,9 +170,12 @@ void *newtype(PyTypeObject *metaty, PyTypeObject *inittype(PyTypeObject *tyskel) { + static PyObject *modname = 0; PyTypeObject *ty = newtype(&PyType_Type, tyskel, 0); + if (!modname) modname = PyString_FromString("catacomb"); ty->tp_flags |= Py_TPFLAGS_HEAPTYPE; PyType_Ready(ty); + PyDict_SetItemString(ty->tp_dict, "__module__", modname); return (ty); }