Update of /cvsroot/pywin32/pywin32/com/win32com/client
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27962/com/win32com/client
Modified Files:
Tag: py3k
__init__.py build.py combrowse.py dynamic.py genpy.py
makepy.py tlbrowse.py
Log Message:
merge recent UnicodeType, string module and NeedUnicodeConversions changes from trunk
Index: makepy.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/makepy.py,v
retrieving revision 1.25.2.5
retrieving revision 1.25.2.6
diff -C2 -d -r1.25.2.5 -r1.25.2.6
*** makepy.py 27 Nov 2008 11:31:04 -0000 1.25.2.5
--- makepy.py 4 Dec 2008 05:08:41 -0000 1.25.2.6
***************
*** 69,73 ****
import sys, os, pythoncom
from win32com.client import genpy, selecttlb, gencache
! from win32com.client import NeedUnicodeConversions, Dispatch
bForDemandDefault = 0 # Default value of bForDemand - toggle this to change the world - see also gencache.py
--- 69,73 ----
import sys, os, pythoncom
from win32com.client import genpy, selecttlb, gencache
! from win32com.client import Dispatch
bForDemandDefault = 0 # Default value of bForDemand - toggle this to change the world - see also gencache.py
***************
*** 211,215 ****
sys.exit(1)
! def GenerateFromTypeLibSpec(typelibInfo, file = None, verboseLevel = None, progressInstance = None, bUnicodeToString=NeedUnicodeConversions, bForDemand = bForDemandDefault, bBuildHidden = 1):
if verboseLevel is None:
verboseLevel = 0 # By default, we use no gui and no verbose level!
--- 211,216 ----
sys.exit(1)
! def GenerateFromTypeLibSpec(typelibInfo, 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!
***************
*** 252,256 ****
for typelib, info in typelibs:
! gen = genpy.Generator(typelib, info.dll, progress, bUnicodeToString=bUnicodeToString, bBuildHidden=bBuildHidden)
if file is None:
--- 253,257 ----
for typelib, info in typelibs:
! gen = genpy.Generator(typelib, info.dll, progress, bBuildHidden=bBuildHidden)
if file is None:
***************
*** 287,291 ****
progress.Close()
! def GenerateChildFromTypeLibSpec(child, typelibInfo, verboseLevel = None, progressInstance = None, bUnicodeToString=NeedUnicodeConversions):
if verboseLevel is None:
verboseLevel = 0 # By default, we use no gui, and no verbose level for the children.
--- 288,293 ----
progress.Close()
! def GenerateChildFromTypeLibSpec(child, typelibInfo, verboseLevel = None, progressInstance = None, bUnicodeToString=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.
***************
*** 313,317 ****
progress.LogBeginGenerate(dir_path_name)
! gen = genpy.Generator(typelib, info.dll, progress, bUnicodeToString=bUnicodeToString)
gen.generate_child(child, dir_path_name)
progress.SetDescription("Importing module")
--- 315,319 ----
progress.LogBeginGenerate(dir_path_name)
! gen = genpy.Generator(typelib, info.dll, progress)
gen.generate_child(child, dir_path_name)
progress.SetDescription("Importing module")
***************
*** 322,326 ****
import getopt
hiddenSpec = 1
- bUnicodeToString = NeedUnicodeConversions
outputName = None
verboseLevel = 1
--- 324,327 ----
***************
*** 332,337 ****
if o=='-h':
hiddenSpec = 0
- elif o=='-u':
- bUnicodeToString = not NeedUnicodeConversions
elif o=='-o':
outputName = v
--- 333,336 ----
Index: dynamic.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/dynamic.py,v
retrieving revision 1.22.2.6
retrieving revision 1.22.2.7
diff -C2 -d -r1.22.2.6 -r1.22.2.7
*** dynamic.py 27 Nov 2008 11:31:04 -0000 1.22.2.6
--- dynamic.py 4 Dec 2008 05:08:41 -0000 1.22.2.7
***************
*** 27,31 ****
import win32com.client # Needed as code we eval() references it.
- from win32com.client import NeedUnicodeConversions
debugging=0 # General debugging
--- 27,30 ----
***************
*** 106,110 ****
return entry.desc[4]
! def Dispatch(IDispatch, userName = None, createClass = None, typeinfo = None, UnicodeToString=NeedUnicodeConversions, clsctx = pythoncom.CLSCTX_SERVER):
IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch,userName,clsctx)
if createClass is None:
--- 105,110 ----
return entry.desc[4]
! def Dispatch(IDispatch, 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:
***************
*** 123,127 ****
typeinfo = None
olerepr = MakeOleRepr(IDispatch, typeinfo, lazydata)
! return createClass(IDispatch, olerepr, userName,UnicodeToString, lazydata)
def MakeOleRepr(IDispatch, typeinfo, typecomp):
--- 123,127 ----
typeinfo = None
olerepr = MakeOleRepr(IDispatch, typeinfo, lazydata)
! return createClass(IDispatch, olerepr, userName, lazydata=lazydata)
def MakeOleRepr(IDispatch, typeinfo, typecomp):
***************
*** 147,159 ****
return olerepr
! def DumbDispatch(IDispatch, userName = None, createClass = None,UnicodeToString=NeedUnicodeConversions, clsctx=pythoncom.CLSCTX_SERVER):
"Dispatch with no type info"
IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch,userName,clsctx)
if createClass is None:
createClass = CDispatch
! return createClass(IDispatch, build.DispatchItem(), userName,UnicodeToString)
class CDispatch:
! def __init__(self, IDispatch, olerepr, userName = None, UnicodeToString=NeedUnicodeConversions, lazydata = None):
if userName is None: userName = "<unknown>"
self.__dict__['_oleobj_'] = IDispatch
--- 147,161 ----
return olerepr
! 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"
if userName is None: userName = "<unknown>"
self.__dict__['_oleobj_'] = IDispatch
***************
*** 163,167 ****
self.__dict__['_builtMethods_'] = {}
self.__dict__['_enum_'] = None
! self.__dict__['_unicode_to_string_'] = UnicodeToString
self.__dict__['_lazydata_'] = lazydata
--- 165,169 ----
self.__dict__['_builtMethods_'] = {}
self.__dict__['_enum_'] = None
! self.__dict__['_unicode_to_string_'] = None
self.__dict__['_lazydata_'] = lazydata
***************
*** 263,269 ****
return self._get_good_object_(result, user, resultCLSID)
! def _wrap_dispatch_(self, ob, userName = None, returnCLSID = None, UnicodeToString = NeedUnicodeConversions):
# Given a dispatch object, wrap it in a class
! return Dispatch(ob, userName, UnicodeToString=UnicodeToString)
def _get_good_single_object_(self,ob,userName = None, ReturnCLSID=None):
--- 265,272 ----
return self._get_good_object_(result, user, resultCLSID)
! def _wrap_dispatch_(self, ob, userName = None, returnCLSID = None, UnicodeToString=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):
Index: combrowse.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/combrowse.py,v
retrieving revision 1.8.2.4
retrieving revision 1.8.2.5
diff -C2 -d -r1.8.2.4 -r1.8.2.5
*** combrowse.py 27 Nov 2008 11:31:04 -0000 1.8.2.4
--- combrowse.py 4 Dec 2008 05:08:41 -0000 1.8.2.5
***************
*** 171,175 ****
else:
try:
! lcid = string.atof(subKey)
lcidkey = win32api.RegOpenKey(key, subKey)
# Enumerate the platforms
--- 171,175 ----
else:
try:
! lcid = int(subKey)
lcidkey = win32api.RegOpenKey(key, subKey)
# Enumerate the platforms
***************
*** 207,211 ****
extraDescs.append("locale=%s"%lcid)
extraDesc = ""
! if extraDescs: extraDesc = " (%s)" % string.join(extraDescs, ", ")
ret.append(HLITypeLib(fname, "Type Library" + extraDesc))
ret.sort()
--- 207,211 ----
extraDescs.append("locale=%s"%lcid)
extraDesc = ""
! if extraDescs: extraDesc = " (%s)" % ", ".join(extraDescs)
ret.append(HLITypeLib(fname, "Type Library" + extraDesc))
ret.sort()
***************
*** 440,444 ****
flagDescs.append(desc)
if flagDescs:
! ret.append(browser.MakeHLI(string.join(flagDescs, ", "), "Function Flags"))
return ret
--- 440,444 ----
flagDescs.append(desc)
if flagDescs:
! ret.append(browser.MakeHLI(", ".join(flagDescs), "Function Flags"))
return ret
***************
*** 499,503 ****
break
try:
! versionFlt = string.atof(versionStr)
except ValueError:
versionFlt = 0 # ????
--- 499,503 ----
break
try:
! versionFlt = float(versionStr)
except ValueError:
versionFlt = 0 # ????
Index: __init__.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/__init__.py,v
retrieving revision 1.34.4.5
retrieving revision 1.34.4.6
diff -C2 -d -r1.34.4.5 -r1.34.4.6
*** __init__.py 27 Nov 2008 11:31:04 -0000 1.34.4.5
--- __init__.py 4 Dec 2008 05:08:41 -0000 1.34.4.6
***************
*** 7,13 ****
# with dynamic.Dispatch behaviour, where dynamic objects are always used.
- # This can go away
- NeedUnicodeConversions = False
-
import pythoncom
from . import dynamic
--- 7,10 ----
***************
*** 20,24 ****
def __WrapDispatch(dispatch, userName = None, resultCLSID = None, typeinfo = None, \
! UnicodeToString = NeedUnicodeConversions, clsctx = pythoncom.CLSCTX_SERVER,
WrapperClass = None):
"""
--- 17,21 ----
def __WrapDispatch(dispatch, userName = None, resultCLSID = None, typeinfo = None, \
! UnicodeToString=None, clsctx = pythoncom.CLSCTX_SERVER,
WrapperClass = None):
"""
***************
*** 26,29 ****
--- 23,27 ----
otherwise cope by using CDispatch.
"""
+ assert UnicodeToString is None, "this is deprecated and will go away"
if resultCLSID is None:
try:
***************
*** 43,47 ****
# Return a "dynamic" object - best we can do!
if WrapperClass is None: WrapperClass = CDispatch
! return dynamic.Dispatch(dispatch, userName, WrapperClass, typeinfo, UnicodeToString=UnicodeToString,clsctx=clsctx)
--- 41,45 ----
# Return a "dynamic" object - best we can do!
if WrapperClass is None: WrapperClass = CDispatch
! return dynamic.Dispatch(dispatch, userName, WrapperClass, typeinfo, clsctx=clsctx)
***************
*** 89,103 ****
moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname)
dispatch = moniker.BindToObject(bindCtx, None, pythoncom.IID_IDispatch)
! return __WrapDispatch(dispatch, Pathname, clsctx = clsctx)
! def Dispatch(dispatch, userName = None, resultCLSID = None, typeinfo = None, UnicodeToString=NeedUnicodeConversions, clsctx = pythoncom.CLSCTX_SERVER):
"""Creates a Dispatch based COM object.
"""
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
! return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx)
! def DispatchEx(clsid, machine=None, userName = None, resultCLSID = None, typeinfo = None, UnicodeToString=NeedUnicodeConversions, clsctx = None):
"""Creates a Dispatch based COM object on a specific machine.
"""
# 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
--- 87,103 ----
moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname)
dispatch = moniker.BindToObject(bindCtx, None, pythoncom.IID_IDispatch)
! return __WrapDispatch(dispatch, Pathname, clsctx=clsctx)
! def Dispatch(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)
! def DispatchEx(clsid, machine=None, 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
***************
*** 112,116 ****
if userName is None: userName = clsid
dispatch = pythoncom.CoCreateInstanceEx(clsid, None, clsctx, serverInfo, (pythoncom.IID_IDispatch,))[0]
! return Dispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString=UnicodeToString, clsctx=clsctx)
class CDispatch(dynamic.CDispatch):
--- 112,116 ----
if userName is None: userName = clsid
dispatch = pythoncom.CoCreateInstanceEx(clsid, None, clsctx, serverInfo, (pythoncom.IID_IDispatch,))[0]
! return Dispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)
class CDispatch(dynamic.CDispatch):
***************
*** 121,126 ****
if/when possible.
"""
! def _wrap_dispatch_(self, ob, userName = None, returnCLSID = None, UnicodeToString = NeedUnicodeConversions):
! return Dispatch(ob, userName, returnCLSID,None,UnicodeToString)
def CastTo(ob, target):
--- 121,127 ----
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 CastTo(ob, target):
***************
*** 473,477 ****
def _get_good_single_object_(obj, obUserName=None, resultCLSID=None):
if _PyIDispatchType==type(obj):
! return Dispatch(obj, obUserName, resultCLSID, UnicodeToString=NeedUnicodeConversions)
return obj
--- 474,478 ----
def _get_good_single_object_(obj, obUserName=None, resultCLSID=None):
if _PyIDispatchType==type(obj):
! return Dispatch(obj, obUserName, resultCLSID)
return obj
Index: build.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/build.py,v
retrieving revision 1.31.2.5
retrieving revision 1.31.2.6
diff -C2 -d -r1.31.2.5 -r1.31.2.6
*** build.py 27 Nov 2008 05:33:25 -0000 1.31.2.5
--- build.py 4 Dec 2008 05:08:41 -0000 1.31.2.6
***************
*** 22,29 ****
from keyword import iskeyword
- from win32com.client import NeedUnicodeConversions
import pythoncom
! from pywintypes import UnicodeType, TimeType
import winerror
--- 22,28 ----
from keyword import iskeyword
import pythoncom
! from pywintypes import TimeType
import winerror
***************
*** 353,365 ****
s = s + "%s\t\texcept pythoncom.error:\n" % (linePrefix,)
s = s + "%s\t\t\treturn ret\n" % (linePrefix,)
! s = s + '%s\t\tret = Dispatch(ret, %s, %s, UnicodeToString=%d)\n' % (linePrefix,repr(name), resclsid, NeedUnicodeConversions)
s = s + '%s\treturn ret' % (linePrefix)
elif rd == pythoncom.VT_BSTR:
! if NeedUnicodeConversions:
! s = "%s\t# Result is a Unicode object - perform automatic string conversion\n" % (linePrefix,)
! s = s + '%s\treturn str(self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s))' % (linePrefix, id, fdesc[4], retDesc, repr(argsDesc), _BuildArgList(fdesc, names))
! else:
! s = "%s\t# Result is a Unicode object - return as-is for this version of Python\n" % (linePrefix,)
! s = s + '%s\treturn self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, repr(argsDesc), _BuildArgList(fdesc, names))
# else s remains None
if s is None:
--- 352,360 ----
s = s + "%s\t\texcept pythoncom.error:\n" % (linePrefix,)
s = s + "%s\t\t\treturn ret\n" % (linePrefix,)
! s = s + '%s\t\tret = Dispatch(ret, %s, %s)\n' % (linePrefix,repr(name), resclsid)
s = s + '%s\treturn ret' % (linePrefix)
elif rd == pythoncom.VT_BSTR:
! s = "%s\t# Result is a Unicode object\n" % (linePrefix,)
! s = s + '%s\treturn self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, repr(argsDesc), _BuildArgList(fdesc, names))
# else s remains None
if s is None:
***************
*** 558,564 ****
# hack for Unicode until it repr's better.
val = defArgVal[2]
! if type(val) is UnicodeType:
! return repr(str(val))
! elif type(val) is TimeType:
year=val.year; month=val.month; day=val.day; hour=val.hour; minute=val.minute; second=val.second; msec=val.msec
return "pythoncom.MakeTime((%(year)d, %(month)d, %(day)d, %(hour)d, %(minute)d, %(second)d,0,0,0,%(msec)d))" % locals()
--- 553,557 ----
# hack for Unicode until it repr's better.
val = defArgVal[2]
! if type(val) is TimeType:
year=val.year; month=val.month; day=val.day; hour=val.hour; minute=val.minute; second=val.second; msec=val.msec
return "pythoncom.MakeTime((%(year)d, %(month)d, %(day)d, %(hour)d, %(minute)d, %(second)d,0,0,0,%(msec)d))" % locals()
Index: genpy.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/genpy.py,v
retrieving revision 1.55.2.6
retrieving revision 1.55.2.7
diff -C2 -d -r1.55.2.6 -r1.55.2.7
*** genpy.py 27 Nov 2008 11:31:04 -0000 1.55.2.6
--- genpy.py 4 Dec 2008 05:08:41 -0000 1.55.2.7
***************
*** 23,27 ****
error = "makepy.error"
! makepy_version = "0.4.98" # Written to generated file.
GEN_FULL="full"
--- 23,27 ----
error = "makepy.error"
! makepy_version = "0.5.00" # Written to generated file.
GEN_FULL="full"
***************
*** 29,39 ****
GEN_DEMAND_CHILD = "demand(child)"
- try:
- TrueRepr = repr(True)
- FalseRepr = repr(False)
- except NameError:
- TrueRepr = "1"
- FalseRepr = "0"
-
# This map is used purely for the users benefit -it shows the
# raw, underlying type of Alias/Enums, etc. The COM implementation
--- 29,32 ----
***************
*** 543,547 ****
print("\t#This class has a __len__ - this is needed so 'if object:' always returns TRUE.", file=stream)
print("\tdef __nonzero__(self):", file=stream)
! print("\t\treturn %s" % (TrueRepr,), file=stream)
class CoClassItem(build.OleItem, WritableItem):
--- 536,540 ----
print("\t#This class has a __len__ - this is needed so 'if object:' always returns TRUE.", file=stream)
print("\tdef __nonzero__(self):", file=stream)
! print("\t\treturn True", file=stream)
class CoClassItem(build.OleItem, WritableItem):
***************
*** 642,646 ****
class Generator:
! def __init__(self, typelib, sourceFilename, progressObject, bBuildHidden=1, bUnicodeToString=0):
self.bHaveWrittenDispatchBaseClass = 0
self.bHaveWrittenCoClassBaseClass = 0
--- 635,640 ----
class Generator:
! def __init__(self, typelib, sourceFilename, progressObject, bBuildHidden=1, bUnicodeToString=None):
! assert bUnicodeToString is None, "this is deprecated and will go away"
self.bHaveWrittenDispatchBaseClass = 0
self.bHaveWrittenCoClassBaseClass = 0
***************
*** 649,653 ****
self.sourceFilename = sourceFilename
self.bBuildHidden = bBuildHidden
- self.bUnicodeToString = bUnicodeToString
self.progress = progressObject
# These 2 are later additions and most of the code still 'print's...
--- 643,646 ----
Index: tlbrowse.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/tlbrowse.py,v
retrieving revision 1.4.4.2
retrieving revision 1.4.4.3
diff -C2 -d -r1.4.4.2 -r1.4.4.3
*** tlbrowse.py 3 Oct 2008 02:30:19 -0000 1.4.4.2
--- tlbrowse.py 4 Dec 2008 05:08:41 -0000 1.4.4.3
***************
*** 2,6 ****
import win32con
import win32api
- import string
import commctrl
import pythoncom
--- 2,5 ----
|