# HG changeset patch # User Oleg Oshmyan # Date 1311699042 -10800 # Node ID 9ed34ef740a1b2576105ab3902a1532ccbb026fd # Parent 4df9537ed2613af0cd9d9607ae18d0954142089f The interrupt handler pipe is now closed on module creation failure diff -r 4df9537ed261 -r 9ed34ef740a1 upreckon/_unixmodule.cpp --- a/upreckon/_unixmodule.cpp Tue Jul 26 19:45:24 2011 +0300 +++ b/upreckon/_unixmodule.cpp Tue Jul 26 19:50:42 2011 +0300 @@ -1326,7 +1326,7 @@ #endif { struct termios new_termios; - PyObject *exceptions; + PyObject *exceptions, *module; _unix__PopenPlaceholderType.tp_new = PyType_GenericNew; if (PyType_Ready(&_unix__PopenPlaceholderType) == -1) @@ -1406,6 +1406,23 @@ PySignal_SetWakeupFd(intpipe[1]); #endif +#if PY_MAJOR_VERSION >= 3 + module = PyModule_Create(&_unixmodule); +#else + module = Py_InitModule("_unix", _unixMethods); +#endif + if (module == NULL) + { + close(intpipe[0]); + close(intpipe[1]); + Py_DECREF(MemoryLimitExceeded); + Py_DECREF(CPUTimeLimitExceeded); + Py_DECREF(WallTimeLimitExceeded); + Py_DECREF(CanceledByUser); + Py_DECREF(CannotStartTestee); + INIT_FAIL; + } + #ifdef HAVE_TERMIOS_H if (!tcgetattr(0, &orig_termios)) { @@ -1429,20 +1446,6 @@ Py_AtExit(close_intpipe); #endif - PyObject *module; -#if PY_MAJOR_VERSION >= 3 - module = PyModule_Create(&_unixmodule); -#else - module = Py_InitModule("_unix", _unixMethods); -#endif - if (module == NULL) - { - Py_DECREF(MemoryLimitExceeded); - Py_DECREF(CPUTimeLimitExceeded); - Py_DECREF(WallTimeLimitExceeded); - Py_DECREF(CanceledByUser); - Py_DECREF(CannotStartTestee); - } #if PY_MAJOR_VERSION >= 3 return module; #endif