[pywin32-checkins] pywin32/com/win32com/src PythonCOM.cpp,1.37,1.38 dllmain.cpp,1.11,1.12
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-11-11 02:37:47
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1320 Modified Files: PythonCOM.cpp dllmain.cpp Log Message: Correct and document behaviour of CoInitializeEx exception throwing behaviour. Also fix what previously appeared to be an optimizer error but turns out to be incorrect calling convention on the function pointer. Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** PythonCOM.cpp 20 Oct 2005 22:36:07 -0000 1.37 --- PythonCOM.cpp 11 Nov 2005 02:37:38 -0000 1.38 *************** *** 523,527 **** return PyCom_BuildPyException(sc); return PyCom_PyObjectFromIUnknown(disp, IID_IDispatch); ! // @comm This function is equivilent to <om pythoncom.GetActiveObject>(clsid).<om pythoncom.QueryInterace>(pythoncom.IID_IDispatch) } #endif // MS_WINCE --- 523,527 ---- return PyCom_BuildPyException(sc); return PyCom_PyObjectFromIUnknown(disp, IID_IDispatch); ! // @comm This function is equivalent to <om pythoncom.GetActiveObject>(clsid).<om pythoncom.QueryInterace>(pythoncom.IID_IDispatch) } #endif // MS_WINCE *************** *** 946,954 **** HRESULT hr = PyCom_CoInitialize(NULL); PY_INTERFACE_POSTCALL; ! if (FAILED(hr)) ! PyCom_BuildPyException(hr); Py_INCREF(Py_None); return Py_None; ! // @comm Equivilent to <om pythoncom.CoInitializeEx>(pythoncom.COINIT_APARTMENTTHREADED). // See <om pythoncom.CoInitializeEx> for a description. } --- 946,964 ---- HRESULT hr = PyCom_CoInitialize(NULL); PY_INTERFACE_POSTCALL; ! // @rdesc This function will ignore the RPC_E_CHANGED_MODE error, as ! // that error indicates someone else beat you to the initialization, and ! // did so with a different threading model. This error is ignored as it ! // still means COM is ready for use on this thread, and as this function ! // does not explicitly specify a threading model the caller probably ! // doesn't care what model it is. ! // <nl>All other COM errors will raise pythoncom.error as usual. Use ! // <om pythoncom.CoInitializeEx> if you also want to handle the RPC_E_CHANGED_MODE ! // error. ! if (FAILED(hr) && hr != RPC_E_CHANGED_MODE) ! return PyCom_BuildPyException(hr); Py_INCREF(Py_None); return Py_None; ! // @comm Apart from the error handling semantics, this is equivalent ! // to <om pythoncom.CoInitializeEx>(pythoncom.COINIT_APARTMENTTHREADED). // See <om pythoncom.CoInitializeEx> for a description. } *************** *** 957,960 **** --- 967,976 ---- static PyObject *pythoncom_CoInitializeEx(PyObject *self, PyObject *args) { + // @rdesc This function will raise pythoncom.error for all error + // return values, including RPC_E_CHANGED_MODE error. This is + // in contrast to <om pythoncom.CoInitialize> which will hide that + // specific error. If your code is happy to work in a threading model + // other than the one you specified, you must explicitly handle + // (and presumably ignore) this exception. DWORD val; if (!PyArg_ParseTuple(args, "l:CoInitializeEx", &val)) *************** *** 965,969 **** PY_INTERFACE_POSTCALL; if (FAILED(hr)) ! PyCom_BuildPyException(hr); Py_INCREF(Py_None); return Py_None; --- 981,985 ---- PY_INTERFACE_POSTCALL; if (FAILED(hr)) ! return PyCom_BuildPyException(hr); Py_INCREF(Py_None); return Py_None; Index: dllmain.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/dllmain.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dllmain.cpp 25 Jan 2005 13:33:15 -0000 1.11 --- dllmain.cpp 11 Nov 2005 02:37:38 -0000 1.12 *************** *** 153,165 **** } ! #ifdef _MSC_VER ! // Wierd problems with optimizer. When anyone ! // calls this, things go very strange. Debugger indicates ! // all params are wierd etc.. ! // Only release mode, of course :-( Dunno what optimization! ! // Compiler version 11.00.7022 ! #pragma optimize ("", off) ! #endif // _MSC_VER ! // Some clients or COM extensions (notably MAPI) are _very_ --- 153,157 ---- } ! typedef HRESULT (WINAPI *PFNCoInitializeEx)(LPVOID pvReserved, DWORD dwCoInit); // Some clients or COM extensions (notably MAPI) are _very_ *************** *** 184,189 **** if (fp==NULL) return E_NOTIMPL; ! HRESULT (*mypfn)(void *pvReserved, DWORD dwCoInit); ! mypfn = (HRESULT (*)(void *pvReserved, DWORD dwCoInit))fp; HRESULT hr = (*mypfn)(reserved, dwInit); --- 176,181 ---- if (fp==NULL) return E_NOTIMPL; ! PFNCoInitializeEx mypfn; ! mypfn = (PFNCoInitializeEx)fp; HRESULT hr = (*mypfn)(reserved, dwInit); *************** *** 205,212 **** return hr; } - #ifdef _MSC_VER - #pragma optimize ("", on) - #endif // _MSC_VER - HRESULT PyCom_CoInitialize(LPVOID reserved) --- 197,200 ---- |