From: Robert Bradshaw Date: Wed, 22 Apr 2009 02:43:22 +0000 (-0700) Subject: more complete embedded mode (trac 291) X-Git-Tag: 0.11.2.rc1~52^2~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8868ff82298d3f3150690e05613cb7dd7af9b3e4;p=cython.git more complete embedded mode (trac 291) --- diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 8a6364fc..4b20b83b 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -2459,16 +2459,22 @@ static __Pyx_RefnannyAPIStruct *__Pyx_Refnanny = NULL; main_method = UtilityCode( impl = """ int main(int argc, char** argv) { - int r; + int r = 0; + PyObject* m = NULL; Py_Initialize(); PySys_SetArgv(argc, argv); #if PY_MAJOR_VERSION < 3 init%(module_name)s(); #else - PyInit_%(module_name)s(name); + m = PyInit_%(module_name)s(name); #endif - r = PyErr_Occurred() != NULL; + if (PyErr_Occurred() != NULL) { + r = 1; + PyErr_Print(); /* This exits with the right code if SystemExit. */ + if (Py_FlushLine()); PyErr_Clear(); + } + Py_XDECREF(m); Py_Finalize(); return r; } -""") \ No newline at end of file +""")