Commit 15fe5e18 authored by Stefan Behnel's avatar Stefan Behnel

make embedding code for PEP 489 less hackish by using the official C-API functions

parent 65cbfd1d
...@@ -33,14 +33,17 @@ static int __Pyx_main(int argc, wchar_t **argv) { ...@@ -33,14 +33,17 @@ static int __Pyx_main(int argc, wchar_t **argv) {
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
init%(module_name)s(); init%(module_name)s();
#elif CYTHON_PEP489_MULTI_PHASE_INIT #elif CYTHON_PEP489_MULTI_PHASE_INIT
{ m = PyInit_%(module_name)s();
if (!PyModule_Check(m)) {
PyModuleDef *mdef = (PyModuleDef *) m;
PyObject *modname = PyUnicode_FromString("__main__"); PyObject *modname = PyUnicode_FromString("__main__");
m = NULL;
if (modname) { if (modname) {
// FIXME: not currently calling create() here because we do not have a module spec! // FIXME: not currently calling PyModule_FromDefAndSpec() here because we do not have a module spec!
// FIXME: not currently setting __file__, __path__, __spec__, ... // FIXME: not currently setting __file__, __path__, __spec__, ...
m = PyModule_NewObject(modname); m = PyModule_NewObject(modname);
Py_DECREF(modname); Py_DECREF(modname);
if (m) __pyx_pymod_exec_%(module_name)s(m); if (m) PyModule_ExecDef(m, mdef);
} }
} }
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment