summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/helpers.c')
-rw-r--r--plugins/pychrysalide/helpers.c79
1 files changed, 56 insertions, 23 deletions
diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c
index 179f03b..0ca133f 100644
--- a/plugins/pychrysalide/helpers.c
+++ b/plugins/pychrysalide/helpers.c
@@ -1570,27 +1570,46 @@ PyObject *_attach_constants_group(const char *owner, PyObject *dict, bool flags,
kwargs = PyDict_New();
dot = rindex(owner, '.');
- assert(dot != NULL);
- module = strndup(owner, dot - owner);
+ if (dot == NULL)
+ {
+ str_obj = PyUnicode_FromString(owner);
+ ret = PyDict_SetItemString(kwargs, "module", str_obj);
+ Py_DECREF(str_obj);
- str_obj = PyUnicode_FromString(module);
- ret = PyDict_SetItemString(kwargs, "module", str_obj);
- Py_DECREF(str_obj);
+ if (ret != 0) goto kwargs_error;
- free(module);
+ str_obj = PyUnicode_FromString(name);
+ ret = PyDict_SetItemString(kwargs, "qualname", str_obj);
+ Py_DECREF(str_obj);
- asprintf(&qualname, "%s.%s", dot + 1, name);
+ if (ret != 0) goto kwargs_error;
- if (ret != 0) goto kwargs_error;
+ }
- str_obj = PyUnicode_FromString(qualname);
- ret = PyDict_SetItemString(kwargs, "qualname", str_obj);
- Py_DECREF(str_obj);
+ else
+ {
+ module = strndup(owner, dot - owner);
- free(qualname);
+ str_obj = PyUnicode_FromString(module);
+ ret = PyDict_SetItemString(kwargs, "module", str_obj);
+ Py_DECREF(str_obj);
- if (ret != 0) goto kwargs_error;
+ free(module);
+
+ if (ret != 0) goto kwargs_error;
+
+ asprintf(&qualname, "%s.%s", dot + 1, name);
+
+ 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 */
@@ -1762,19 +1781,35 @@ PyObject *_cast_with_constants_group(const char *owner, const char *name, unsign
/* Recherche de la classe Python */
dot = strrchr(owner, '.');
- assert(dot != NULL);
- modname = strndup(owner, dot - owner);
+ if (dot == NULL)
+ {
+ module = get_access_to_python_module(owner);
+
+ if (module == NULL)
+ goto no_mod;
- module = get_access_to_python_module(modname);
+ type = module;
+ Py_INCREF(type);
- if (module == NULL)
- goto no_mod;
+ }
+ else
+ {
+ modname = strndup(owner, dot - owner);
- type = PyObject_GetAttrString(module, dot + 1);
+ module = get_access_to_python_module(modname);
- if (type == NULL)
- goto no_type;
+ free(modname);
+
+ if (module == NULL)
+ goto no_mod;
+
+ type = PyObject_GetAttrString(module, dot + 1);
+
+ if (type == NULL)
+ goto no_type;
+
+ }
class = PyObject_GetAttrString(type, name);
@@ -1798,8 +1833,6 @@ PyObject *_cast_with_constants_group(const char *owner, const char *name, unsign
no_type:
no_mod:
- free(modname);
-
return result;
}