Mercurial > ~astiob > upreckon > hgweb
comparison upreckon/_unixmodule.cpp @ 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 | d5b6708c1955 |
children | 0bd782fd41dc |
comparison
equal
deleted
inserted
replaced
184:4df9537ed261 | 185:9ed34ef740a1 |
---|---|
1324 #define INIT_FAIL return | 1324 #define INIT_FAIL return |
1325 PyMODINIT_FUNC init_unix(void) | 1325 PyMODINIT_FUNC init_unix(void) |
1326 #endif | 1326 #endif |
1327 { | 1327 { |
1328 struct termios new_termios; | 1328 struct termios new_termios; |
1329 PyObject *exceptions; | 1329 PyObject *exceptions, *module; |
1330 | 1330 |
1331 _unix__PopenPlaceholderType.tp_new = PyType_GenericNew; | 1331 _unix__PopenPlaceholderType.tp_new = PyType_GenericNew; |
1332 if (PyType_Ready(&_unix__PopenPlaceholderType) == -1) | 1332 if (PyType_Ready(&_unix__PopenPlaceholderType) == -1) |
1333 { | 1333 { |
1334 INIT_FAIL; | 1334 INIT_FAIL; |
1404 } | 1404 } |
1405 | 1405 |
1406 PySignal_SetWakeupFd(intpipe[1]); | 1406 PySignal_SetWakeupFd(intpipe[1]); |
1407 #endif | 1407 #endif |
1408 | 1408 |
1409 #if PY_MAJOR_VERSION >= 3 | |
1410 module = PyModule_Create(&_unixmodule); | |
1411 #else | |
1412 module = Py_InitModule("_unix", _unixMethods); | |
1413 #endif | |
1414 if (module == NULL) | |
1415 { | |
1416 close(intpipe[0]); | |
1417 close(intpipe[1]); | |
1418 Py_DECREF(MemoryLimitExceeded); | |
1419 Py_DECREF(CPUTimeLimitExceeded); | |
1420 Py_DECREF(WallTimeLimitExceeded); | |
1421 Py_DECREF(CanceledByUser); | |
1422 Py_DECREF(CannotStartTestee); | |
1423 INIT_FAIL; | |
1424 } | |
1425 | |
1409 #ifdef HAVE_TERMIOS_H | 1426 #ifdef HAVE_TERMIOS_H |
1410 if (!tcgetattr(0, &orig_termios)) | 1427 if (!tcgetattr(0, &orig_termios)) |
1411 { | 1428 { |
1412 new_termios = orig_termios; | 1429 new_termios = orig_termios; |
1413 // Stolen from tty.py of Python 2.7.1 | 1430 // Stolen from tty.py of Python 2.7.1 |
1427 #endif | 1444 #endif |
1428 #elif defined USE_WAKEUP_FD | 1445 #elif defined USE_WAKEUP_FD |
1429 Py_AtExit(close_intpipe); | 1446 Py_AtExit(close_intpipe); |
1430 #endif | 1447 #endif |
1431 | 1448 |
1432 PyObject *module; | |
1433 #if PY_MAJOR_VERSION >= 3 | |
1434 module = PyModule_Create(&_unixmodule); | |
1435 #else | |
1436 module = Py_InitModule("_unix", _unixMethods); | |
1437 #endif | |
1438 if (module == NULL) | |
1439 { | |
1440 Py_DECREF(MemoryLimitExceeded); | |
1441 Py_DECREF(CPUTimeLimitExceeded); | |
1442 Py_DECREF(WallTimeLimitExceeded); | |
1443 Py_DECREF(CanceledByUser); | |
1444 Py_DECREF(CannotStartTestee); | |
1445 } | |
1446 #if PY_MAJOR_VERSION >= 3 | 1449 #if PY_MAJOR_VERSION >= 3 |
1447 return module; | 1450 return module; |
1448 #endif | 1451 #endif |
1449 } | 1452 } |