From 97779f15e6d16a3446596512c7f2f87ab22b6ae7 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Wed, 9 Sep 2026 15:05:08 +0200 Subject: [PATCH] avoid using internal functions from Python C API --- src/runtime/python/pypgf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/runtime/python/pypgf.c b/src/runtime/python/pypgf.c index fe8228241..38385baf6 100644 --- a/src/runtime/python/pypgf.c +++ b/src/runtime/python/pypgf.c @@ -1614,12 +1614,13 @@ PGF_embed(PGFObject* self, PyObject *modname) py_embedding->dict = PyDict_New(); } else { py_embedding->dict = PyModule_GetDict(module); + if (py_embedding->dict == NULL) + return NULL; Py_INCREF(py_embedding->dict); } - if (_PyImport_SetModule(modname, (PyObject*) py_embedding) < 0) { - return NULL; - } + PyObject *modules = PyImport_GetModuleDict(); + PyDict_SetItem(modules, modname, (PyObject*) py_embedding); return (PyObject*) py_embedding; }