Skip to content

Commit

Permalink
Remove deprecated UnicodeToString param (#2143)
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam authored Mar 14, 2024
1 parent e2906a8 commit 9903dc7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 31 deletions.
13 changes: 2 additions & 11 deletions com/win32com/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ def __WrapDispatch(
userName=None,
resultCLSID=None,
typeinfo=None,
UnicodeToString=None,
clsctx=pythoncom.CLSCTX_SERVER,
WrapperClass=None,
):
"""
Helper function to return a makepy generated class for a CLSID if it exists,
otherwise cope by using CDispatch.
"""
assert UnicodeToString is None, "this is deprecated and will go away"
if resultCLSID is None:
try:
typeinfo = dispatch.GetTypeInfo()
Expand Down Expand Up @@ -110,11 +108,9 @@ def Dispatch(
userName=None,
resultCLSID=None,
typeinfo=None,
UnicodeToString=None,
clsctx=pythoncom.CLSCTX_SERVER,
):
"""Creates a Dispatch based COM object."""
assert UnicodeToString is None, "this is deprecated and will go away"
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)
return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)

Expand All @@ -125,11 +121,9 @@ def DispatchEx(
userName=None,
resultCLSID=None,
typeinfo=None,
UnicodeToString=None,
clsctx=None,
):
"""Creates a Dispatch based COM object on a specific machine."""
assert UnicodeToString is None, "this is deprecated and will go away"
# If InProc is registered, DCOM will use it regardless of the machine name
# (and regardless of the DCOM config for the object.) So unless the user
# specifies otherwise, we exclude inproc apps when a remote machine is used.
Expand Down Expand Up @@ -157,11 +151,8 @@ class CDispatch(dynamic.CDispatch):
if/when possible.
"""

def _wrap_dispatch_(
self, ob, userName=None, returnCLSID=None, UnicodeToString=None
):
assert UnicodeToString is None, "this is deprecated and will go away"
return Dispatch(ob, userName, returnCLSID, None)
def _wrap_dispatch_(self, ob, userName=None, returnCLSID=None):
return Dispatch(ob, userName, returnCLSID)

def __dir__(self):
return dynamic.CDispatch.__dir__(self)
Expand Down
15 changes: 5 additions & 10 deletions com/win32com/client/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,8 @@ def Dispatch(
userName=None,
createClass=None,
typeinfo=None,
UnicodeToString=None,
clsctx=pythoncom.CLSCTX_SERVER,
):
assert UnicodeToString is None, "this is deprecated and will go away"
IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch, userName, clsctx)
if createClass is None:
createClass = CDispatch
Expand Down Expand Up @@ -181,22 +179,17 @@ def DumbDispatch(
IDispatch,
userName=None,
createClass=None,
UnicodeToString=None,
clsctx=pythoncom.CLSCTX_SERVER,
):
"Dispatch with no type info"
assert UnicodeToString is None, "this is deprecated and will go away"
IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch, userName, clsctx)
if createClass is None:
createClass = CDispatch
return createClass(IDispatch, build.DispatchItem(), userName)


class CDispatch:
def __init__(
self, IDispatch, olerepr, userName=None, UnicodeToString=None, lazydata=None
):
assert UnicodeToString is None, "this is deprecated and will go away"
def __init__(self, IDispatch, olerepr, userName=None, lazydata=None):
if userName is None:
userName = "<unknown>"
self.__dict__["_oleobj_"] = IDispatch
Expand Down Expand Up @@ -370,10 +363,12 @@ def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *ar
return self._get_good_object_(result, user, resultCLSID)

def _wrap_dispatch_(
self, ob, userName=None, returnCLSID=None, UnicodeToString=None
self,
ob,
userName=None,
returnCLSID=None,
):
# Given a dispatch object, wrap it in a class
assert UnicodeToString is None, "this is deprecated and will go away"
return Dispatch(ob, userName)

def _get_good_single_object_(self, ob, userName=None, ReturnCLSID=None):
Expand Down
2 changes: 0 additions & 2 deletions com/win32com/client/genpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,7 @@ def __init__(
sourceFilename,
progressObject,
bBuildHidden=1,
bUnicodeToString=None,
):
assert bUnicodeToString is None, "this is deprecated and will go away"
self.bHaveWrittenDispatchBaseClass = 0
self.bHaveWrittenCoClassBaseClass = 0
self.bHaveWrittenEventBaseClass = 0
Expand Down
5 changes: 1 addition & 4 deletions com/win32com/client/makepy.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,9 @@ def GenerateFromTypeLibSpec(
file=None,
verboseLevel=None,
progressInstance=None,
bUnicodeToString=None,
bForDemand=bForDemandDefault,
bBuildHidden=1,
):
assert bUnicodeToString is None, "this is deprecated and will go away"
if verboseLevel is None:
verboseLevel = 0 # By default, we use no gui and no verbose level!

Expand Down Expand Up @@ -338,9 +336,8 @@ def GenerateFromTypeLibSpec(


def GenerateChildFromTypeLibSpec(
child, typelibInfo, verboseLevel=None, progressInstance=None, bUnicodeToString=None
child, typelibInfo, verboseLevel=None, progressInstance=None
):
assert bUnicodeToString is None, "this is deprecated and will go away"
if verboseLevel is None:
verboseLevel = (
0 # By default, we use no gui, and no verbose level for the children.
Expand Down
5 changes: 1 addition & 4 deletions com/win32comext/adsi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ def __GetIndex(self, index):


class ADSIDispatch(win32com.client.CDispatch):
def _wrap_dispatch_(
self, ob, userName=None, returnCLSID=None, UnicodeToString=None
):
assert UnicodeToString is None, "this is deprectated and will be removed"
def _wrap_dispatch_(self, ob, userName=None, returnCLSID=None):
if not userName:
userName = "ADSI-object"
olerepr = win32com.client.dynamic.MakeOleRepr(ob, None, None)
Expand Down

0 comments on commit 9903dc7

Please sign in to comment.