Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25507/com/win32com/src/extensions
Modified Files:
PyGErrorLog.cpp PyGPropertyBag.cpp PyICatInformation.cpp
PyIEnumCATEGORYINFO.cpp PyIMoniker.cpp PyIPropertyStorage.cpp
PyIStorage.cpp
Log Message:
Lots of stuff from Roger's work on the py3k branch:
* Lots of string and 64bit enhancements, particularly
in pythonwin which only accepted plain string objects
in many cases. pywintypes and some of the other extension
code get cleanups in this area too.
* Consolidation of more structure conversions and other helpers
into pywintypes.
* Additional pythonwin tooltip notification fixes.
* Some '#if (PY_VERSION_HEX < 0x03000000)' blocks have been
incorporated, but in general, no py3k specific code has
been merged yet.
* Better error handling in pythonwin; less exceptions should be
left lingering, be overridden or simply ignored.
* Drop support for pythoncom.__future_currency__ - the
decimal module is now always used.
* A couple of very early interface implementations are upgraded to have
unicode passed instead of strings - if you *implement* (not use) any
of these interfaces, you may need to test to ensure you work when
args are passed as unicode objects instead of strings. Affected are
IErrorLog, IPropertyBag, ICatInformation and IStorage.
Index: PyIMoniker.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIMoniker.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PyIMoniker.cpp 2 Nov 2003 09:56:42 -0000 1.4
--- PyIMoniker.cpp 13 Nov 2008 04:04:51 -0000 1.5
***************
*** 299,312 ****
if (S_OK!=hr) // S_OK only acceptable
return PyCom_BuildPyException(hr, pMy, IID_IMoniker);
! PyObject *obResult = PyString_FromUnicode(result);
!
! IMalloc *pMalloc = NULL;
! #ifndef MS_WINCE // So how do I fix this leak on CE?
! CoGetMalloc(1, &pMalloc);
! #endif
! if (pMalloc) {
! pMalloc->Free(result);
! pMalloc->Release();
! }
return obResult;
}
--- 299,304 ----
if (S_OK!=hr) // S_OK only acceptable
return PyCom_BuildPyException(hr, pMy, IID_IMoniker);
! PyObject *obResult = PyWinObject_FromWCHAR(result);
! CoTaskMemFree(result);
return obResult;
}
Index: PyIEnumCATEGORYINFO.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIEnumCATEGORYINFO.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** PyIEnumCATEGORYINFO.cpp 2 Nov 2003 09:57:44 -0000 1.6
--- PyIEnumCATEGORYINFO.cpp 13 Nov 2008 04:04:51 -0000 1.7
***************
*** 64,68 ****
{
PyObject *obNewIID = PyWinObject_FromIID(rgVar[i].catid);
! PyObject *ob = Py_BuildValue("OiN", obNewIID, rgVar[i].lcid, PyString_FromUnicode(rgVar[i].szDescription));
Py_XDECREF(obNewIID);
if ( ob == NULL )
--- 64,68 ----
{
PyObject *obNewIID = PyWinObject_FromIID(rgVar[i].catid);
! PyObject *ob = Py_BuildValue("OiN", obNewIID, rgVar[i].lcid, PyWinObject_FromWCHAR(rgVar[i].szDescription));
Py_XDECREF(obNewIID);
if ( ob == NULL )
Index: PyIStorage.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIStorage.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PyIStorage.cpp 25 Jan 2005 13:33:16 -0000 1.4
--- PyIStorage.cpp 13 Nov 2008 04:04:51 -0000 1.5
***************
*** 551,555 ****
if (ppstm==NULL) return E_POINTER;
PyObject *result;
! PyObject *obName = PyString_FromUnicode(pwcsName);
HRESULT hr=InvokeViaPolicy("CreateStream", &result, "Oiii", obName, grfMode, reserved1, reserved2);
Py_XDECREF(obName);
--- 551,555 ----
if (ppstm==NULL) return E_POINTER;
PyObject *result;
! PyObject *obName = PyWinObject_FromWCHAR(pwcsName);
HRESULT hr=InvokeViaPolicy("CreateStream", &result, "Oiii", obName, grfMode, reserved1, reserved2);
Py_XDECREF(obName);
***************
*** 577,581 ****
if (ppstm==NULL) return E_POINTER;
PyObject *result;
! PyObject *obName = PyString_FromUnicode(pwcsName);
HRESULT hr=InvokeViaPolicy("OpenStream", &result, "Ozii", obName, NULL, grfMode, reserved2);
Py_XDECREF(obName);
--- 577,581 ----
if (ppstm==NULL) return E_POINTER;
PyObject *result;
! PyObject *obName = PyWinObject_FromWCHAR(pwcsName);
HRESULT hr=InvokeViaPolicy("OpenStream", &result, "Ozii", obName, NULL, grfMode, reserved2);
Py_XDECREF(obName);
***************
*** 603,607 ****
if (ppstg==NULL) return E_POINTER;
PyObject *result;
! PyObject *obName = PyString_FromUnicode(pwcsName);
HRESULT hr=InvokeViaPolicy("CreateStorage", &result, "Oiii", obName, grfMode, dwStgFmt, reserved2);
Py_XDECREF(obName);
--- 603,607 ----
if (ppstg==NULL) return E_POINTER;
PyObject *result;
! PyObject *obName = PyWinObject_FromWCHAR(pwcsName);
HRESULT hr=InvokeViaPolicy("CreateStorage", &result, "Oiii", obName, grfMode, dwStgFmt, reserved2);
Py_XDECREF(obName);
***************
*** 634,638 ****
PyObject *obpstgPriority = PyCom_PyObjectFromIUnknown(pstgPriority, IID_IStorage, TRUE);
PyObject *result;
! PyObject *obName = PyString_FromUnicode(pwcsName);
HRESULT hr=InvokeViaPolicy("OpenStorage", &result, "OOizi", obName, obpstgPriority, grfMode, NULL, reserved);
Py_XDECREF(obName);
--- 634,638 ----
PyObject *obpstgPriority = PyCom_PyObjectFromIUnknown(pstgPriority, IID_IStorage, TRUE);
PyObject *result;
! PyObject *obName = PyWinObject_FromWCHAR(pwcsName);
HRESULT hr=InvokeViaPolicy("OpenStorage", &result, "OOizi", obName, obpstgPriority, grfMode, NULL, reserved);
Py_XDECREF(obName);
***************
*** 677,682 ****
PY_GATEWAY_METHOD;
PyObject *obpstgDest = PyCom_PyObjectFromIUnknown(pstgDest, IID_IStorage, TRUE);
! PyObject *obName = PyString_FromUnicode(pwcsName);
! PyObject *obNewName = PyString_FromUnicode(pwcsNewName);
HRESULT hr=InvokeViaPolicy("MoveElementTo", NULL, "OOOi", obName, obpstgDest, obNewName, grfFlags);
Py_XDECREF(obpstgDest);
--- 677,682 ----
PY_GATEWAY_METHOD;
PyObject *obpstgDest = PyCom_PyObjectFromIUnknown(pstgDest, IID_IStorage, TRUE);
! PyObject *obName = PyWinObject_FromWCHAR(pwcsName);
! PyObject *obNewName = PyWinObject_FromWCHAR(pwcsNewName);
HRESULT hr=InvokeViaPolicy("MoveElementTo", NULL, "OOOi", obName, obpstgDest, obNewName, grfFlags);
Py_XDECREF(obpstgDest);
***************
*** 729,733 ****
{
PY_GATEWAY_METHOD;
! PyObject *obName = PyString_FromUnicode(pwcsName);
HRESULT hr=InvokeViaPolicy("DestroyElement", NULL, "O", obName);
Py_XDECREF(obName);
--- 729,733 ----
{
PY_GATEWAY_METHOD;
! PyObject *obName = PyWinObject_FromWCHAR(pwcsName);
HRESULT hr=InvokeViaPolicy("DestroyElement", NULL, "O", obName);
Py_XDECREF(obName);
***************
*** 740,745 ****
{
PY_GATEWAY_METHOD;
! PyObject *obOldName = PyString_FromUnicode(pwcsOldName);
! PyObject *obNewName = PyString_FromUnicode(pwcsNewName);
HRESULT hr=InvokeViaPolicy("RenameElement", NULL, "OO", obOldName, obNewName);
Py_XDECREF(obOldName);
--- 740,745 ----
{
PY_GATEWAY_METHOD;
! PyObject *obOldName = PyWinObject_FromWCHAR(pwcsOldName);
! PyObject *obNewName = PyWinObject_FromWCHAR(pwcsNewName);
HRESULT hr=InvokeViaPolicy("RenameElement", NULL, "OO", obOldName, obNewName);
Py_XDECREF(obOldName);
***************
*** 755,762 ****
{
PY_GATEWAY_METHOD;
! PyObject *obpctime = new PyTime(*pctime);
! PyObject *obpatime = new PyTime(*patime);
! PyObject *obpmtime = new PyTime(*pmtime);
! PyObject *obName = PyString_FromUnicode(pwcsName);
HRESULT hr=InvokeViaPolicy("SetElementTimes", NULL, "OOOO", obName, obpctime, obpatime, obpmtime);
Py_XDECREF(obpctime);
--- 755,762 ----
{
PY_GATEWAY_METHOD;
! PyObject *obpctime = PyWinObject_FromFILETIME(*pctime);
! PyObject *obpatime = PyWinObject_FromFILETIME(*patime);
! PyObject *obpmtime = PyWinObject_FromFILETIME(*pmtime);
! PyObject *obName = PyWinObject_FromWCHAR(pwcsName);
HRESULT hr=InvokeViaPolicy("SetElementTimes", NULL, "OOOO", obName, obpctime, obpatime, obpmtime);
Py_XDECREF(obpctime);
Index: PyGPropertyBag.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyGPropertyBag.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PyGPropertyBag.cpp 19 Nov 1999 04:03:23 -0000 1.2
--- PyGPropertyBag.cpp 13 Nov 2008 04:04:51 -0000 1.3
***************
*** 26,30 ****
}
! PyObject *obName = PyString_FromUnicode(pszPropName); // keep with string for b/w compat.
PyObject *result;
HRESULT hr = InvokeViaPolicy("Read",
--- 26,30 ----
}
! PyObject *obName = PyWinObject_FromWCHAR(pszPropName);
PyObject *result;
HRESULT hr = InvokeViaPolicy("Read",
***************
*** 57,61 ****
return PyCom_SetCOMErrorFromPyException(GetIID());
! PyObject *obName = PyString_FromUnicode(pszPropName); // keep with string for b/w compat.
HRESULT hr = InvokeViaPolicy("Write",
NULL,
--- 57,61 ----
return PyCom_SetCOMErrorFromPyException(GetIID());
! PyObject *obName = PyWinObject_FromWCHAR(pszPropName);
HRESULT hr = InvokeViaPolicy("Write",
NULL,
Index: PyGErrorLog.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyGErrorLog.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PyGErrorLog.cpp 19 Nov 1999 04:03:23 -0000 1.2
--- PyGErrorLog.cpp 13 Nov 2008 04:04:51 -0000 1.3
***************
*** 16,21 ****
return PyCom_SetCOMErrorFromPyException(GetIID());
! // We use a string object for B/W compatibility.
! PyObject *obName = PyString_FromUnicode(pszPropName);
HRESULT hr = InvokeViaPolicy("AddError",
NULL,
--- 16,20 ----
return PyCom_SetCOMErrorFromPyException(GetIID());
! PyObject *obName = PyWinObject_FromWCHAR(pszPropName);
HRESULT hr = InvokeViaPolicy("AddError",
NULL,
Index: PyIPropertyStorage.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIPropertyStorage.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** PyIPropertyStorage.cpp 22 Aug 2007 19:57:40 -0000 1.13
--- PyIPropertyStorage.cpp 13 Nov 2008 04:04:51 -0000 1.14
***************
*** 25,29 ****
PyObject *sub = PyTuple_GET_ITEM(tuple, i);
if (PyUnicode_Check(sub))
! cChars += PyUnicode_Size(sub) + 1;
else if (PyString_Check(sub))
cChars += PyString_Size(sub) + 1;
--- 25,29 ----
PyObject *sub = PyTuple_GET_ITEM(tuple, i);
if (PyUnicode_Check(sub))
! cChars += PyUnicode_GET_SIZE(sub) + 1;
else if (PyString_Check(sub))
cChars += PyString_Size(sub) + 1;
Index: PyICatInformation.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyICatInformation.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** PyICatInformation.cpp 9 Apr 2004 11:27:04 -0000 1.5
--- PyICatInformation.cpp 13 Nov 2008 04:04:51 -0000 1.6
***************
*** 134,140 ****
if (S_OK!=hr) // S_OK only acceptable
return PyCom_BuildPyException(hr, pMy, IID_ICatInformation);
! // @comm The return type is a true PyString, not a Uniocode object.
! // @todo Upgrade the return type to be Unicode.
! PyObject *rc = PyString_FromUnicode(pResult);
CoTaskMemFree(pResult);
return rc;
--- 134,139 ----
if (S_OK!=hr) // S_OK only acceptable
return PyCom_BuildPyException(hr, pMy, IID_ICatInformation);
! PyObject *rc = PyWinObject_FromWCHAR(pResult);
! // @comm The return type is a unicode object.
CoTaskMemFree(pResult);
return rc;
|