Update of /cvsroot/pywin32/pywin32/com/win32com/client
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv816/com/win32com/client
Modified Files:
dynamic.py
Log Message:
The 'user name' (really the 'display name') of a COM object should never
be unicode.
Index: dynamic.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/dynamic.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** dynamic.py 9 Apr 2004 11:22:45 -0000 1.20
--- dynamic.py 10 Jan 2006 00:51:15 -0000 1.21
***************
*** 43,47 ****
winerror.DISP_E_PARAMNOTOPTIONAL,
winerror.DISP_E_TYPEMISMATCH,
! winerror.E_INVALIDARG,
]
--- 43,47 ----
winerror.DISP_E_PARAMNOTOPTIONAL,
winerror.DISP_E_TYPEMISMATCH,
! winerror.E_INVALIDARG,
]
***************
*** 65,72 ****
print
! # get the dispatch type in use.
dispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]
iunkType = pythoncom.TypeIIDs[pythoncom.IID_IUnknown]
- _StringOrUnicodeType=[StringType, UnicodeType]
_GoodDispatchType=[StringType,IIDType,UnicodeType]
_defaultDispatchItem=build.DispatchItem
--- 65,71 ----
print
! # get the type objects for IDispatch and IUnknown
dispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]
iunkType = pythoncom.TypeIIDs[pythoncom.IID_IUnknown]
_GoodDispatchType=[StringType,IIDType,UnicodeType]
_defaultDispatchItem=build.DispatchItem
***************
*** 83,92 ****
return IDispatch
! def _GetGoodDispatchAndUserName(IDispatch,userName,clsctx):
if userName is None:
! if type(IDispatch) in _StringOrUnicodeType:
userName = IDispatch
! else:
! userName = "<unknown>"
return (_GetGoodDispatch(IDispatch, clsctx), userName)
--- 82,99 ----
return IDispatch
! def _GetGoodDispatchAndUserName(IDispatch, userName, clsctx):
! # Get a dispatch object, and a 'user name' (ie, the name as
! # displayed to the user in repr() etc.
if userName is None:
! if type(IDispatch) == StringType:
userName = IDispatch
! elif type(IDispatch) == UnicodeType:
! # We always want the displayed name to be a real string
! userName = IDispatch.encode("ascii", "replace")
! elif type(userName) == UnicodeType:
! # As above - always a string...
! userName = userName.encode("ascii", "replace")
! else:
! userName = str(userName)
return (_GetGoodDispatch(IDispatch, clsctx), userName)
|