[pywin32-checkins] pywin32/win32/src PyOVERLAPPED.cpp,1.11,1.12
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2007-01-19 23:05:33
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15762/win32/src Modified Files: PyOVERLAPPED.cpp Log Message: Fix places where HANDLEs treated as longs Return -1 when setting an attribute fails Index: PyOVERLAPPED.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyOVERLAPPED.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PyOVERLAPPED.cpp 22 Sep 2006 14:31:32 -0000 1.11 --- PyOVERLAPPED.cpp 19 Jan 2007 23:05:30 -0000 1.12 *************** *** 141,145 **** return pO->m_obHandle; } ! return PyInt_FromLong((long)pO->m_overlapped.hEvent); } // @prop object|object|Any python object that you want to attach to your overlapped I/O request. --- 141,145 ---- return pO->m_obHandle; } ! return PyWinLong_FromHANDLE(pO->m_overlapped.hEvent); } // @prop object|object|Any python object that you want to attach to your overlapped I/O request. *************** *** 173,185 **** if (strcmp("hEvent", name)==0) { PyOVERLAPPED *pO = (PyOVERLAPPED *)self; Py_XDECREF(pO->m_obHandle); - pO->m_obHandle = NULL; if (PyHANDLE_Check(v)) { pO->m_obHandle = v; - PyWinObject_AsHANDLE(v, &pO->m_overlapped.hEvent, FALSE); Py_INCREF(v); ! } else if (PyInt_Check(v)) { ! pO->m_overlapped.hEvent = (HANDLE)PyInt_AsLong(v); ! } return 0; } --- 173,188 ---- if (strcmp("hEvent", name)==0) { PyOVERLAPPED *pO = (PyOVERLAPPED *)self; + // Use an intermediate so the original isn't lost if conversion fails + HANDLE htmp; + if (!PyWinObject_AsHANDLE(v, &htmp, FALSE)) + return -1; + pO->m_overlapped.hEvent=htmp; Py_XDECREF(pO->m_obHandle); if (PyHANDLE_Check(v)) { pO->m_obHandle = v; Py_INCREF(v); ! } ! else ! pO->m_obHandle = NULL; return 0; } *************** *** 195,202 **** { PyOVERLAPPED *pO = (PyOVERLAPPED *)self; ! PyErr_Clear(); ! pO->m_overlapped.dwValue = PyInt_AsLong(v); ! if (PyErr_Occurred()) ! PyErr_SetString(PyExc_TypeError, "The 'dword' value must be an integer"); return 0; } --- 198,205 ---- { PyOVERLAPPED *pO = (PyOVERLAPPED *)self; ! DWORD dwordtmp=PyInt_AsLong(v); ! if ((dwordtmp==(DWORD)-1) && PyErr_Occurred()) ! return -1; ! pO->m_overlapped.dwValue=dwordtmp; return 0; } |