avoid using internal functions from Python C API

This commit is contained in:
Krasimir Angelov
2026-09-09 15:05:08 +02:00
parent a3b19e585d
commit 97779f15e6
+4 -3
View File
@@ -1614,12 +1614,13 @@ PGF_embed(PGFObject* self, PyObject *modname)
py_embedding->dict = PyDict_New(); py_embedding->dict = PyDict_New();
} else { } else {
py_embedding->dict = PyModule_GetDict(module); py_embedding->dict = PyModule_GetDict(module);
if (py_embedding->dict == NULL)
return NULL;
Py_INCREF(py_embedding->dict); Py_INCREF(py_embedding->dict);
} }
if (_PyImport_SetModule(modname, (PyObject*) py_embedding) < 0) { PyObject *modules = PyImport_GetModuleDict();
return NULL; PyDict_SetItem(modules, modname, (PyObject*) py_embedding);
}
return (PyObject*) py_embedding; return (PyObject*) py_embedding;
} }