diff options
Diffstat (limited to 'plugins/pychrysalide/helpers.c')
-rw-r--r-- | plugins/pychrysalide/helpers.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c index 59bcd45..5b7c1e6 100644 --- a/plugins/pychrysalide/helpers.c +++ b/plugins/pychrysalide/helpers.c @@ -28,8 +28,10 @@ #include <malloc.h> #include <pygobject.h> #include <stdarg.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <strings.h> #include <i18n.h> @@ -1003,6 +1005,9 @@ bool attach_constants_group(PyTypeObject *owner, bool flags, const char *name, P int ret; /* Bilan d'une insertion */ PyObject *args; /* Arguments de la construction*/ PyObject *kwargs; /* Mots clefs en complément */ + char *dot; /* Point de séparation */ + char *module; /* Module d'appartenance */ + char *qualname; /* Désignation pour Pickle */ PyObject *new; /* Nouvelle instance en place */ PyObject *features; /* Module à recompléter */ PyObject *features_dict; /* Dictionnaire à compléter */ @@ -1046,10 +1051,27 @@ bool attach_constants_group(PyTypeObject *owner, bool flags, const char *name, P kwargs = PyDict_New(); - str_obj = PyUnicode_FromString(owner->tp_name); + dot = rindex(owner->tp_name, '.'); + assert(dot != NULL); + + module = strndup(owner->tp_name, dot - owner->tp_name); + + str_obj = PyUnicode_FromString(module); ret = PyDict_SetItemString(kwargs, "module", str_obj); Py_DECREF(str_obj); + free(module); + + asprintf(&qualname, "%s.%s", dot + 1, name); + + if (ret != 0) goto kwargs_error; + + str_obj = PyUnicode_FromString(qualname); + ret = PyDict_SetItemString(kwargs, "qualname", str_obj); + Py_DECREF(str_obj); + + free(qualname); + if (ret != 0) goto kwargs_error; /* Constitution de l'énumération et enregistrement */ |