[pywin32-checkins] /hgroot/pywin32/pywin32: 5 new changesets
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2012-08-06 02:10:23
|
changeset c7cffbcd27e5 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=c7cffbcd27e5 summary: Prevent pythoncom.WrapObject() double releasing a reference now PyCom_PyObjectFromIUnknown has saner error behaviour changeset dafd0153cb25 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=dafd0153cb25 summary: Avoid temp objects when making result values, mainly in makepy generated code changeset 53d276dfdc4b in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=53d276dfdc4b summary: Ensure IEnum* interfaces release references on error changeset 3d96807807b5 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=3d96807807b5 summary: a couple more minor cleanups while reviewing PyCom_PyObjectFromIUnknown error handling change changeset 02686d59297d in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=02686d59297d summary: Use PYCOM_RELEASE() in more places diffstat: com/win32com/src/ErrorUtils.cpp | 4 +- com/win32com/src/PyComHelpers.cpp | 6 +- com/win32com/src/PyIUnknown.cpp | 6 +- com/win32com/src/PythonCOM.cpp | 61 ++++----- com/win32com/src/extensions/PyIEnumConnectionPoints.cpp | 8 +- com/win32com/src/extensions/PyIEnumConnections.cpp | 11 +- com/win32com/src/extensions/PyIMoniker.cpp | 22 +-- com/win32com/src/extensions/PyIPropertyStorage.cpp | 7 +- com/win32com/src/extensions/PyIStorage.cpp | 5 +- com/win32com/src/extensions/PyIType.cpp | 6 +- com/win32com/src/include/PythonCOM.h | 12 + com/win32com/src/oleargs.cpp | 12 +- com/win32com/src/univgw.cpp | 10 +- com/win32comext/axcontrol/src/PyIObjectWithSite.cpp | 7 +- com/win32comext/axcontrol/src/PyIOleClientSite.cpp | 14 +- com/win32comext/axcontrol/src/PyIOleInPlaceSite.cpp | 12 +- com/win32comext/axcontrol/src/PyIOleObject.cpp | 35 +---- com/win32comext/axcontrol/src/PyIViewObject.cpp | 8 +- com/win32comext/axdebug/src/PyIActiveScriptDebug.cpp | 5 +- com/win32comext/axdebug/src/PyIActiveScriptErrorDebug.cpp | 14 +- com/win32comext/axdebug/src/PyIActiveScriptSiteDebug.cpp | 19 +-- com/win32comext/axdebug/src/PyIApplicationDebugger.cpp | 7 +- com/win32comext/axdebug/src/PyIDebugApplication.cpp | 19 +-- com/win32comext/axdebug/src/PyIDebugApplicationNode.cpp | 14 +- com/win32comext/axdebug/src/PyIDebugCodeContext.cpp | 7 +- com/win32comext/axdebug/src/PyIDebugDocumentContext.cpp | 14 +- com/win32comext/axdebug/src/PyIDebugDocumentHelper.cpp | 22 +-- com/win32comext/axdebug/src/PyIDebugDocumentHost.cpp | 7 +- com/win32comext/axdebug/src/PyIDebugDocumentProvider.cpp | 5 +- com/win32comext/axdebug/src/PyIDebugDocumentText.cpp | 7 +- com/win32comext/axdebug/src/PyIDebugExpression.cpp | 6 +- com/win32comext/axdebug/src/PyIDebugExpressionContext.cpp | 7 +- com/win32comext/axdebug/src/PyIDebugProperties.cpp | 20 +-- com/win32comext/axdebug/src/PyIDebugStackFrame.cpp | 21 +-- com/win32comext/axdebug/src/PyIDebugStackFrameSniffer.cpp | 7 +- com/win32comext/axdebug/src/PyIDebugSyncOperation.cpp | 14 +- com/win32comext/axdebug/src/PyIEnumDebugApplicationNodes.cpp | 6 +- com/win32comext/axdebug/src/PyIEnumDebugCodeContexts.cpp | 6 +- com/win32comext/axdebug/src/PyIEnumDebugExpressionContexts.cpp | 6 +- com/win32comext/axdebug/src/PyIEnumDebugStackFrames.cpp | 7 +- com/win32comext/axdebug/src/PyIEnumRemoteDebugApplicationThreads.cpp | 6 +- com/win32comext/axdebug/src/PyIEnumRemoteDebugApplications.cpp | 6 +- com/win32comext/axdebug/src/PyIMachineDebugManager.cpp | 5 +- com/win32comext/axdebug/src/PyIProcessDebugManager.cpp | 14 +- com/win32comext/axdebug/src/PyIProvideExpressionContexts.cpp | 7 +- com/win32comext/axdebug/src/PyIRemoteDebugApplication.cpp | 11 +- com/win32comext/bits/src/PyIBackgroundCopyManager.cpp | 21 +-- com/win32comext/bits/src/PyIEnumBackgroundCopyFiles.cpp | 6 +- com/win32comext/bits/src/PyIEnumBackgroundCopyJobs.cpp | 6 +- com/win32comext/shell/src/PyIEnumExplorerCommand.cpp | 6 +- com/win32comext/shell/src/PyIShellView.cpp | 6 +- com/win32comext/shell/src/shell.cpp | 49 +------ com/win32comext/taskscheduler/src/PyITaskScheduler.cpp | 8 +- 53 files changed, 150 insertions(+), 487 deletions(-) diffs (truncated from 1571 to 300 lines): diff -r eb5c1ebf9472 -r 02686d59297d com/win32com/src/ErrorUtils.cpp --- a/com/win32com/src/ErrorUtils.cpp Sat Aug 04 20:35:38 2012 -0400 +++ b/com/win32com/src/ErrorUtils.cpp Mon Aug 06 12:04:10 2012 +1000 @@ -596,9 +596,7 @@ Py_END_ALLOW_THREADS if (hr==S_OK) { obEI = PyCom_PyObjectFromIErrorInfo(pEI, errorhr); - Py_BEGIN_ALLOW_THREADS - pEI->Release(); - Py_END_ALLOW_THREADS + PYCOM_RELEASE(pEI); } } } diff -r eb5c1ebf9472 -r 02686d59297d com/win32com/src/PyComHelpers.cpp --- a/com/win32com/src/PyComHelpers.cpp Sat Aug 04 20:35:38 2012 -0400 +++ b/com/win32com/src/PyComHelpers.cpp Mon Aug 06 12:04:10 2012 +1000 @@ -104,11 +104,7 @@ // caller is asking us to take ownership of the COM reference. If we // fail to create a Python object, we must release the reference. #define POFIU_RELEASE_ON_FAILURE \ - if (!bAddRef) { \ - PY_INTERFACE_PRECALL; \ - punk->Release(); \ - PY_INTERFACE_POSTCALL; \ - } + if (!bAddRef) PYCOM_RELEASE(punk) // Interface conversions diff -r eb5c1ebf9472 -r 02686d59297d com/win32com/src/PyIUnknown.cpp --- a/com/win32com/src/PyIUnknown.cpp Sat Aug 04 20:35:38 2012 -0400 +++ b/com/win32com/src/PyIUnknown.cpp Mon Aug 06 12:04:10 2012 +1000 @@ -245,11 +245,7 @@ PyErr_Clear(); rc = PyCom_PyObjectFromIUnknown(punk, useIID, TRUE); } - { - PY_INTERFACE_PRECALL; - punk->Release(); - PY_INTERFACE_POSTCALL; - } + PYCOM_RELEASE(punk); return rc; } diff -r eb5c1ebf9472 -r 02686d59297d com/win32com/src/PythonCOM.cpp --- a/com/win32com/src/PythonCOM.cpp Sat Aug 04 20:35:38 2012 -0400 +++ b/com/win32com/src/PythonCOM.cpp Mon Aug 06 12:04:10 2012 +1000 @@ -269,6 +269,12 @@ PyObject *obNew; if (mqi[i].hr==0) obNew = PyCom_PyObjectFromIUnknown(mqi[i].pItf, *mqi[i].pIID, FALSE); + mqi[i].pItf = NULL; + if (!obNew) { + Py_DECREF(result); + result = NULL; + goto done; + } else { obNew = Py_None; Py_INCREF(Py_None); @@ -276,14 +282,11 @@ PyTuple_SET_ITEM(result, i, obNew); } done: - if (punk) { - PY_INTERFACE_PRECALL; - punk->Release(); - PY_INTERFACE_POSTCALL; - } + PYCOM_RELEASE(punk); if (serverInfo.pwszName) PyWinObject_FreeWCHAR(serverInfo.pwszName); + for (i=0;i<numIIDs;i++) PYCOM_RELEASE(mqi[i].pItf) delete [] iids; delete [] mqi; return result; @@ -734,19 +737,8 @@ PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr); - - /* pass the pDispatch reference into this thing */ - /* ### this guy should always AddRef() ... */ - PyObject *result = PyCom_PyObjectFromIUnknown(pDispatch, iidInterface, FALSE); - if ( !result ) - { - PY_INTERFACE_PRECALL; - pDispatch->Release(); - PY_INTERFACE_POSTCALL; - return NULL; - } - - return result; + /* return a PyObject wrapping it */ + return PyCom_PyObjectFromIUnknown(pDispatch, iidInterface, FALSE); } static PyObject *pythoncom_MakeIID(PyObject *self, PyObject *args) @@ -794,7 +786,10 @@ } /* pass the pBC ref into obBindCtx */ - obBindCtx = PyCom_PyObjectFromIUnknown(pBC, IID_IBindCtx, FALSE); + if (!(obBindCtx = PyCom_PyObjectFromIUnknown(pBC, IID_IBindCtx, FALSE))) { + PyWinObject_FreeWCHAR(displayName); + return NULL; + } } else { @@ -807,7 +802,10 @@ Py_INCREF(obBindCtx); pBC->Release(); } - /* at this point: we own a ref to obBindCtx, but not pBC */ + /* at this point: we own a ref to obBindCtx, but not a direct one on pBC + (obBindCtx itself has an indirect reference to pBC though, so it is still + safe to use ...) + */ ULONG chEaten; IMoniker *pmk; PY_INTERFACE_PRECALL; @@ -819,18 +817,11 @@ Py_DECREF(obBindCtx); return PyCom_BuildPyException(hr); } - - /* pass ownership of the moniker into the result */ - PyObject *obMoniker = PyCom_PyObjectFromIUnknown(pmk, IID_IMoniker, FALSE); - /* build the result */ - PyObject *result = Py_BuildValue("OiO", obMoniker, chEaten, obBindCtx); - - /* done with these obs */ - Py_XDECREF(obMoniker); - Py_DECREF(obBindCtx); - - return result; + return Py_BuildValue("NiN", + PyCom_PyObjectFromIUnknown(pmk, IID_IMoniker, FALSE), + chEaten, + obBindCtx); } // @pymethod <o PyIMoniker>|pythoncom|CreatePointerMoniker|Creates a new <o PyIMoniker> object. @@ -942,7 +933,7 @@ PyCom_BuildPyException(hr); else ret=PyCom_PyObjectFromIUnknown(output_moniker, IID_IMoniker, FALSE); - } + } PyWinObject_FreeWCHAR(url); return ret; } @@ -1259,7 +1250,7 @@ PyCom_BuildPyException(hr); else ret=PyCom_PyObjectFromIUnknown(pIUnknown, riid, FALSE); - } + } return ret; } @@ -1402,9 +1393,7 @@ IStream *pStream; if (!PyCom_InterfaceFromPyObject(obStream, IID_IStream, (void **)&pStream, FALSE)) { - PY_INTERFACE_PRECALL; - if(pPersist) pPersist->Release(); - PY_INTERFACE_POSTCALL; + PYCOM_RELEASE(pPersist); return NULL; } diff -r eb5c1ebf9472 -r 02686d59297d com/win32com/src/extensions/PyIEnumConnectionPoints.cpp --- a/com/win32com/src/extensions/PyIEnumConnectionPoints.cpp Sat Aug 04 20:35:38 2012 -0400 +++ b/com/win32com/src/extensions/PyIEnumConnectionPoints.cpp Mon Aug 06 12:04:10 2012 +1000 @@ -58,13 +58,12 @@ } PyObject *result = PyTuple_New(celtFetched); - if ( result != NULL ) - { + if (result) { for ( i = celtFetched; i--; ) { PyObject *ob = PyCom_PyObjectFromIUnknown(rgVar[i], IID_IConnectionPoint, FALSE); - if ( ob == NULL ) - { + rgVar[i] = NULL; + if ( ob == NULL ) { Py_DECREF(result); result = NULL; break; @@ -72,6 +71,7 @@ PyTuple_SET_ITEM(result, i, ob); } } + for ( i = celtFetched; i--; ) PYCOM_RELEASE(rgVar[i]); delete [] rgVar; return result; } diff -r eb5c1ebf9472 -r 02686d59297d com/win32com/src/extensions/PyIEnumConnections.cpp --- a/com/win32com/src/extensions/PyIEnumConnections.cpp Sat Aug 04 20:35:38 2012 -0400 +++ b/com/win32com/src/extensions/PyIEnumConnections.cpp Mon Aug 06 12:04:10 2012 +1000 @@ -56,21 +56,20 @@ } PyObject *result = PyTuple_New(celtFetched); - if ( result != NULL ) - { + if (result) { for ( i = celtFetched; i--; ) { PyObject *ob = PyCom_PyObjectFromIUnknown(rgVar[i].pUnk, IID_IUnknown, FALSE); - if ( ob == NULL ) - { + rgVar[i].pUnk = NULL; + if ( ob == NULL ) { Py_DECREF(result); result = NULL; break; } - PyTuple_SET_ITEM(result, i, Py_BuildValue("Ol",ob, rgVar[i].dwCookie)); - Py_DECREF(ob); + PyTuple_SET_ITEM(result, i, Py_BuildValue("Nl",ob, rgVar[i].dwCookie)); } } + for ( i = celtFetched; i--; ) PYCOM_RELEASE(rgVar[i].pUnk); delete [] rgVar; return result; } diff -r eb5c1ebf9472 -r 02686d59297d com/win32com/src/extensions/PyIMoniker.cpp --- a/com/win32com/src/extensions/PyIMoniker.cpp Sat Aug 04 20:35:38 2012 -0400 +++ b/com/win32com/src/extensions/PyIMoniker.cpp Mon Aug 06 12:04:10 2012 +1000 @@ -53,13 +53,12 @@ } PyObject *result = PyTuple_New(celtFetched); - if ( result != NULL ) - { + if (result) { for ( i = celtFetched; i--; ) { PyObject *ob = PyCom_PyObjectFromIUnknown(rgVar[i], IID_IMoniker, FALSE); - if ( ob == NULL ) - { + rgVar[i] = NULL; + if ( ob == NULL ) { Py_DECREF(result); result = NULL; break; @@ -67,6 +66,7 @@ PyTuple_SET_ITEM(result, i, ob); } } + for ( i = celtFetched; i--; ) PYCOM_RELEASE(rgVar[i]); delete [] rgVar; return result; // @rdesc The result is a tuple of <o PyIID> objects, @@ -183,10 +183,7 @@ IMoniker *pMonLeft = NULL; if (obMoniker!=Py_None) { if (!PyCom_InterfaceFromPyInstanceOrObject(obMoniker, IID_IMoniker, (void **)&pMonLeft, FALSE)) { - PY_INTERFACE_PRECALL; - pBindCtx->Release(); - PY_INTERFACE_POSTCALL; - + PYCOM_RELEASE(pBindCtx); return NULL; } } @@ -234,10 +231,7 @@ IMoniker *pMonLeft = NULL; if (obMoniker!=Py_None) { if (!PyCom_InterfaceFromPyInstanceOrObject(obMoniker, IID_IMoniker, (void **)&pMonLeft, FALSE)) { - PY_INTERFACE_PRECALL; - pBindCtx->Release(); - PY_INTERFACE_POSTCALL; - + PYCOM_RELEASE(pBindCtx); return NULL; } } @@ -284,9 +278,7 @@ IMoniker *pMonLeft = NULL; if (obMoniker!=Py_None) { if (!PyCom_InterfaceFromPyInstanceOrObject(obMoniker, IID_IMoniker, (void **)&pMonLeft, FALSE)) { - PY_INTERFACE_PRECALL; - pBindCtx->Release(); - PY_INTERFACE_POSTCALL; + PYCOM_RELEASE(pBindCtx); return NULL; } } diff -r eb5c1ebf9472 -r 02686d59297d com/win32com/src/extensions/PyIPropertyStorage.cpp --- a/com/win32com/src/extensions/PyIPropertyStorage.cpp Sat Aug 04 20:35:38 2012 -0400 |