[pywin32-checkins] /hgroot/pywin32/pywin32: 4 new changesets
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2012-08-20 23:59:41
|
changeset b1b93d64ad96 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=b1b93d64ad96 summary: Fix a couple of places where BSTR used for WCHAR; GetCurFile should return changeset b44ca63464fc in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=b44ca63464fc summary: Fix a couple of places where BSTR used for WCHAR changeset aff790ba4fba in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=aff790ba4fba summary: Fix a couple of places where BSTR used for WCHAR changeset d6adf5a1b26e in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=d6adf5a1b26e summary: Fix DWORD conversion in Python 2.3 diffstat: SWIG/swig_lib/python/pywintypes.i | 13 ++- com/win32com/src/extensions/PyIPersistFile.cpp | 69 ++++++--------- com/win32comext/shell/src/PyIExplorerBrowser.cpp | 37 +++----- com/win32comext/shell/src/PyIShellBrowser.cpp | 13 +- com/win32comext/shell/src/PyIShellIconOverlayManager.cpp | 35 +++----- 5 files changed, 73 insertions(+), 94 deletions(-) diffs (truncated from 356 to 300 lines): diff -r 54ec13f605a5 -r d6adf5a1b26e SWIG/swig_lib/python/pywintypes.i --- a/SWIG/swig_lib/python/pywintypes.i Mon Aug 20 02:23:41 2012 -0400 +++ b/SWIG/swig_lib/python/pywintypes.i Mon Aug 20 19:51:40 2012 -0400 @@ -47,7 +47,18 @@ // PyLong_AsUnsignedLongMask isn't ideal - no overflow checking - but // this is what the 'k' format specifier in PyArg_ParseTuple uses, and // that is what much of pywin32 uses for DWORDS, so we use it here too - $target = PyLong_AsUnsignedLongMask($source); + // Also, Python 2.3 and below will not accept a plain int for the PyLong_* functions + #if (PY_VERSION_HEX < 0x02400000) + { + PyObject *tmpLong = PyNumber_Long($source); + if (tmpLong == NULL) + return NULL; + $target = PyLong_AsUnsignedLongMask(tmpLong); + Py_DECREF(tmpLong); + } + #else + $target = PyLong_AsUnsignedLongMask($source); + #endif if ($target==(DWORD)-1 && PyErr_Occurred()) return NULL; } diff -r 54ec13f605a5 -r d6adf5a1b26e com/win32com/src/extensions/PyIPersistFile.cpp --- a/com/win32com/src/extensions/PyIPersistFile.cpp Mon Aug 20 02:23:41 2012 -0400 +++ b/com/win32com/src/extensions/PyIPersistFile.cpp Mon Aug 20 19:51:40 2012 -0400 @@ -52,27 +52,24 @@ IPersistFile *pIPF = GetI(self); if ( pIPF == NULL ) return NULL; - // @pyparm <o unicode>|pszFileName||Absolute path of the file to open - // @pyparm int|dwMode|STGM_READ|Specifies the access mode from the STGM enumeration. - PyObject *obpszFileName; - LPOLESTR pszFileName; + // @pyparm str|FileName||Absolute path of the file to open + // @pyparm int|Mode|STGM_READ|Specifies the access mode from the STGM enumeration. + PyObject *obFileName; + TmpWCHAR FileName; DWORD dwMode = STGM_READ; - if ( !PyArg_ParseTuple(args, "O|l:Load", &obpszFileName, &dwMode) ) + if ( !PyArg_ParseTuple(args, "O|l:Load", &obFileName, &dwMode) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (!PyWinObject_AsBstr(obpszFileName, &pszFileName)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyWinObject_AsWCHAR(obFileName, &FileName)) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; - hr = pIPF->Load( pszFileName, dwMode ); + hr = pIPF->Load(FileName, dwMode ); PY_INTERFACE_POSTCALL; - SysFreeString(pszFileName); if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPF, IID_IPersistFile); Py_INCREF(Py_None); return Py_None; - } // @pymethod |PyIPersistFile|Save|Saves the object into the specified file. @@ -81,27 +78,24 @@ IPersistFile *pIPF = GetI(self); if ( pIPF == NULL ) return NULL; - // @pyparm <o unicode>|pszFileName||absolute path of the file where the object is saved. + // @pyparm str|FileName||absolute path of the file where the object is saved. // @pyparm int|fRemember||Specifies whether the file is to be the current working file or not. - PyObject *obpszFileName; - LPOLESTR pszFileName; + PyObject *obFileName; + TmpWCHAR FileName; BOOL fRemember; - if ( !PyArg_ParseTuple(args, "Oi:Save", &obpszFileName, &fRemember) ) + if ( !PyArg_ParseTuple(args, "Oi:Save", &obFileName, &fRemember) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (!PyWinObject_AsBstr(obpszFileName, &pszFileName, TRUE)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyWinObject_AsWCHAR(obFileName, &FileName, TRUE)) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; - hr = pIPF->Save( pszFileName, fRemember ); + hr = pIPF->Save(FileName, fRemember ); PY_INTERFACE_POSTCALL; - SysFreeString(pszFileName); if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPF, IID_IPersistFile); Py_INCREF(Py_None); return Py_None; - } // @pymethod |PyIPersistFile|SaveCompleted|Notifies the object that it can revert from NoScribble mode to Normal mode. @@ -110,28 +104,25 @@ IPersistFile *pIPF = GetI(self); if ( pIPF == NULL ) return NULL; - // @pyparm <o unicode>|pszFileName||Absolute path of the file where the object was saved. - PyObject *obpszFileName; - LPOLESTR pszFileName; - if ( !PyArg_ParseTuple(args, "O:SaveCompleted", &obpszFileName) ) + // @pyparm str|FileName||Absolute path of the file where the object was saved. + PyObject *obFileName; + TmpWCHAR FileName; + if ( !PyArg_ParseTuple(args, "O:SaveCompleted", &obFileName) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (!PyWinObject_AsBstr(obpszFileName, &pszFileName)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyWinObject_AsWCHAR(obFileName, &FileName)) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; - hr = pIPF->SaveCompleted( pszFileName ); + hr = pIPF->SaveCompleted(FileName ); PY_INTERFACE_POSTCALL; - SysFreeString(pszFileName); if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPF, IID_IPersistFile); Py_INCREF(Py_None); return Py_None; - } -// @pymethod <o unicode>|PyIPersistFile|GetCurFile|Gets the current name of the file associated with the object. +// @pymethod str|PyIPersistFile|GetCurFile|Gets the current name of the file associated with the object. PyObject *PyIPersistFile::GetCurFile(PyObject *self, PyObject *args) { IPersistFile *pIPF = GetI(self); @@ -147,11 +138,7 @@ if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPF, IID_IPersistFile); - PyObject *obppszFileName; - - obppszFileName = MakeOLECHARToObj(ppszFileName); - PyObject *pyretval = Py_BuildValue("O", obppszFileName); - Py_XDECREF(obppszFileName); + PyObject *pyretval = MakeOLECHARToObj(ppszFileName); CoTaskMemFree(ppszFileName); return pyretval; } @@ -227,10 +214,10 @@ if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params PyObject *obppszFileName; - if (!PyArg_Parse(result, "O" , &obppszFileName)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); - BOOL bPythonIsHappy = TRUE; - if (!PyWinObject_AsBstr(obppszFileName, ppszFileName)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); + if (!PyArg_Parse(result, "O" , &obppszFileName)) + hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); + else if (!PyWinObject_AsTaskAllocatedWCHAR(obppszFileName, ppszFileName)) + hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); Py_DECREF(result); return hr; } diff -r 54ec13f605a5 -r d6adf5a1b26e com/win32comext/shell/src/PyIExplorerBrowser.cpp --- a/com/win32comext/shell/src/PyIExplorerBrowser.cpp Mon Aug 20 02:23:41 2012 -0400 +++ b/com/win32comext/shell/src/PyIExplorerBrowser.cpp Mon Aug 20 19:51:40 2012 -0400 @@ -113,26 +113,22 @@ IExplorerBrowser *pIEB = GetI(self); if ( pIEB == NULL ) return NULL; - // @pyparm <o unicode>|pszPropertyBag||Description for pszPropertyBag - PyObject *obpszPropertyBag; - LPWSTR pszPropertyBag; - if ( !PyArg_ParseTuple(args, "O:SetPropertyBag", &obpszPropertyBag) ) + // @pyparm str|PropertyBag||Description for pszPropertyBag + PyObject *obPropertyBag; + TmpWCHAR PropertyBag; + if ( !PyArg_ParseTuple(args, "O:SetPropertyBag", &obPropertyBag) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyWinObject_AsBstr(obpszPropertyBag, &pszPropertyBag)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyWinObject_AsWCHAR(obPropertyBag, &PropertyBag)) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; - hr = pIEB->SetPropertyBag( pszPropertyBag ); - SysFreeString(pszPropertyBag); - + hr = pIEB->SetPropertyBag(PropertyBag ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEB, IID_IExplorerBrowser ); Py_INCREF(Py_None); return Py_None; - } // @pymethod |PyIExplorerBrowser|SetEmptyText|Description of SetEmptyText. @@ -141,26 +137,23 @@ IExplorerBrowser *pIEB = GetI(self); if ( pIEB == NULL ) return NULL; - // @pyparm <o unicode>|pszEmptyText||Description for pszEmptyText - PyObject *obpszEmptyText; - LPWSTR pszEmptyText; - if ( !PyArg_ParseTuple(args, "O:SetEmptyText", &obpszEmptyText) ) + // @pyparm str|EmptyText||Description for pszEmptyText + PyObject *obEmptyText; + TmpWCHAR EmptyText; + if ( !PyArg_ParseTuple(args, "O:SetEmptyText", &obEmptyText) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyWinObject_AsBstr(obpszEmptyText, &pszEmptyText)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + + if (!PyWinObject_AsWCHAR(obEmptyText, &EmptyText)) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; - hr = pIEB->SetEmptyText( pszEmptyText ); - SysFreeString(pszEmptyText); - + hr = pIEB->SetEmptyText(EmptyText ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEB, IID_IExplorerBrowser ); Py_INCREF(Py_None); return Py_None; - } // @pymethod |PyIExplorerBrowser|SetFolderSettings|Description of SetFolderSettings. diff -r 54ec13f605a5 -r d6adf5a1b26e com/win32comext/shell/src/PyIShellBrowser.cpp --- a/com/win32comext/shell/src/PyIShellBrowser.cpp Mon Aug 20 02:23:41 2012 -0400 +++ b/com/win32comext/shell/src/PyIShellBrowser.cpp Mon Aug 20 19:51:40 2012 -0400 @@ -121,25 +121,22 @@ IShellBrowser *pISB = GetI(self); if ( pISB == NULL ) return NULL; - PyObject *obpszStatusText; - LPOLESTR pszStatusText; + PyObject *obStatusText; + TmpWCHAR StatusText; if (!PyArg_ParseTuple(args, "O:SetStatusTextSB", - &obpszStatusText)) // @pyparm <o PyUnicode>|pszStatusText||New status to be displayed + &obStatusText)) // @pyparm str|pszStatusText||New status to be displayed return NULL; - if (!PyWinObject_AsBstr(obpszStatusText, &pszStatusText)) + if (!PyWinObject_AsWCHAR(obStatusText, &StatusText)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; - hr = pISB->SetStatusTextSB( pszStatusText ); - SysFreeString(pszStatusText); - + hr = pISB->SetStatusTextSB(StatusText ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); Py_INCREF(Py_None); return Py_None; - } // @pymethod |PyIShellBrowser|EnableModelessSB|Enables or disables modeless dialogs diff -r 54ec13f605a5 -r d6adf5a1b26e com/win32comext/shell/src/PyIShellIconOverlayManager.cpp --- a/com/win32comext/shell/src/PyIShellIconOverlayManager.cpp Mon Aug 20 02:23:41 2012 -0400 +++ b/com/win32comext/shell/src/PyIShellIconOverlayManager.cpp Mon Aug 20 19:51:40 2012 -0400 @@ -24,37 +24,32 @@ return (IShellIconOverlayManager *)PyIUnknown::GetI(self); } -// @pymethod |PyIShellIconOverlayManager|GetFileOverlayInfo|Description of GetFileOverlayInfo. +// @pymethod int|PyIShellIconOverlayManager|GetFileOverlayInfo|Returns an index into the system image list for the icon image or overlay image PyObject *PyIShellIconOverlayManager::GetFileOverlayInfo(PyObject *self, PyObject *args) { IShellIconOverlayManager *pISIOM = GetI(self); if ( pISIOM == NULL ) return NULL; - // @pyparm <o unicode>|path||Description for path - // @pyparm int|attrib||Description for attrib - // @pyparm int|flags||Description for flags + // @pyparm str|path||Full path to the file + // @pyparm int|attrib||File attributes (win32com.FILE_ATTRIBUTE_*) + // @pyparm int|flags||SIOM_OVERLAYINDEX (1) or SIOM_ICONINDEX (2) PyObject *obpath; - LPWSTR path; + TmpWCHAR path; DWORD attrib; int index; DWORD flags; if ( !PyArg_ParseTuple(args, "Oll:GetFileOverlayInfo", &obpath, &attrib, &flags) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyWinObject_AsBstr(obpath, &path)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyWinObject_AsWCHAR(obpath, &path)) |