[pywin32-checkins] pywin32/win32/src win32apimodule.cpp,1.46,1.47
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-03-05 04:42:48
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4695 Modified Files: win32apimodule.cpp Log Message: Fix [ 1075751 ] SetConsoleCtrlHandler rejects ctrlHandler=None and also report errors calling ::SetConsoleCtrlHandler Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** win32apimodule.cpp 4 Mar 2005 11:50:32 -0000 1.46 --- win32apimodule.cpp 5 Mar 2005 04:42:38 -0000 1.47 *************** *** 4563,4566 **** --- 4563,4573 ---- if (!PyArg_ParseTuple(args, "O|i:SetConsoleCtrlHandler", &func, &bAdd)) return NULL; + // Handle special case of None first + if (func == Py_None) { + if (!SetConsoleCtrlHandler(NULL, bAdd)) + return ReturnAPIError("SetConsoleCtrlHandler"); + Py_INCREF(Py_None); + return Py_None; + } if (!PyCallable_Check(func)) return PyErr_Format(PyExc_TypeError, *************** *** 4573,4582 **** return NULL; if (bAdd) { if (0 != PyList_Append(consoleControlHandlers, func)) return NULL; if (!addedCtrlHandler) { ! SetConsoleCtrlHandler(PyCtrlHandler, TRUE); ! addedCtrlHandler = TRUE; } } else { --- 4580,4590 ---- return NULL; + BOOL ok = TRUE; // we may not actually make the call! if (bAdd) { if (0 != PyList_Append(consoleControlHandlers, func)) return NULL; if (!addedCtrlHandler) { ! ok = SetConsoleCtrlHandler(PyCtrlHandler, TRUE); ! addedCtrlHandler = ok; } } else { *************** *** 4593,4600 **** return PyErr_Format(PyExc_ValueError, "The object has not been registered"); if (addedCtrlHandler && PyList_Size(consoleControlHandlers)==0) { ! SetConsoleCtrlHandler(PyCtrlHandler, FALSE); addedCtrlHandler = FALSE; } } Py_INCREF(Py_None); return Py_None; --- 4601,4610 ---- return PyErr_Format(PyExc_ValueError, "The object has not been registered"); if (addedCtrlHandler && PyList_Size(consoleControlHandlers)==0) { ! ok = SetConsoleCtrlHandler(PyCtrlHandler, FALSE); addedCtrlHandler = FALSE; } } + if (!ok) + return ReturnAPIError("SetConsoleCtrlHandler"); Py_INCREF(Py_None); return Py_None; |