Mercurial > ~astiob > upreckon > hgweb
changeset 185:9ed34ef740a1
The interrupt handler pipe is now closed on module creation failure
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Tue, 26 Jul 2011 19:50:42 +0300 |
parents | 4df9537ed261 |
children | 0bd782fd41dc |
files | upreckon/_unixmodule.cpp |
diffstat | 1 files changed, 18 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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