Update of /cvsroot/pywin32/pywin32/com/win32com/client
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20885/client
Modified Files:
Tag: py3k
CLSIDToClass.py __init__.py build.py combrowse.py dynamic.py
gencache.py genpy.py makepy.py selecttlb.py tlbrowse.py
util.py
Log Message:
Changes to build for Py3k
Index: makepy.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/makepy.py,v
retrieving revision 1.25
retrieving revision 1.25.2.1
diff -C2 -d -r1.25 -r1.25.2.1
*** makepy.py 1 Jul 2008 00:17:41 -0000 1.25
--- makepy.py 29 Aug 2008 08:58:53 -0000 1.25.2.1
***************
*** 67,74 ****
"""
! import genpy, string, sys, os, types, pythoncom
! import codecs
! import selecttlb
! import gencache
from win32com.client import NeedUnicodeConversions, Dispatch
--- 67,74 ----
"""
! import sys, os, types, pythoncom
! from win32com.client import genpy
! from . import selecttlb
! from . import gencache
from win32com.client import NeedUnicodeConversions, Dispatch
***************
*** 102,110 ****
else:
desc = tlb.GetDocumentation(-1)[0]
! print desc
! print " %s, lcid=%s, major=%s, minor=%s" % (tlbSpec.clsid, tlbSpec.lcid, tlbSpec.major, tlbSpec.minor)
! print " >>> # Use these commands in Python code to auto generate .py support"
! print " >>> from win32com.client import gencache"
! print " >>> gencache.EnsureModule('%s', %s, %s, %s)" % (tlbSpec.clsid, tlbSpec.lcid, tlbSpec.major, tlbSpec.minor)
class SimpleProgress(genpy.GeneratorProgress):
--- 102,110 ----
else:
desc = tlb.GetDocumentation(-1)[0]
! print(desc)
! print(" %s, lcid=%s, major=%s, minor=%s" % (tlbSpec.clsid, tlbSpec.lcid, tlbSpec.major, tlbSpec.minor))
! print(" >>> # Use these commands in Python code to auto generate .py support")
! print(" >>> from win32com.client import gencache")
! print(" >>> gencache.EnsureModule('%s', %s, %s, %s)" % (tlbSpec.clsid, tlbSpec.lcid, tlbSpec.major, tlbSpec.minor))
class SimpleProgress(genpy.GeneratorProgress):
***************
*** 190,194 ****
pass
if len(tlbs)==0:
! print "Could not locate a type library matching '%s'" % (arg)
for spec in tlbs:
# Version numbers not always reliable if enumerated from registry.
--- 190,194 ----
pass
if len(tlbs)==0:
! print("Could not locate a type library matching '%s'" % (arg))
for spec in tlbs:
# Version numbers not always reliable if enumerated from registry.
***************
*** 218,222 ****
if bForDemand and file is not None:
! raise RuntimeError, "You can only perform a demand-build when the output goes to the gen_py directory"
if type(typelibInfo)==type(()):
# Tuple
--- 218,222 ----
if bForDemand and file is not None:
! raise RuntimeError("You can only perform a demand-build when the output goes to the gen_py directory")
if type(typelibInfo)==type(()):
# Tuple
***************
*** 267,279 ****
else:
outputName = full_name + ".py"
! # generate to a temp file (so errors don't leave a 1/2
! # generated file) and one which can handle unicode!
! try:
! os.unlink(outputName)
! except os.error:
! pass
! encoding = 'mbcs' # could make this a param.
! fileUse = codecs.open(outputName + ".temp", "wt",
! encoding)
progress.LogBeginGenerate(outputName)
else:
--- 267,271 ----
else:
outputName = full_name + ".py"
! fileUse = open(outputName, "wt")
progress.LogBeginGenerate(outputName)
else:
***************
*** 286,290 ****
if file is None:
fileUse.close()
- os.rename(outputName + ".temp", outputName)
if bToGenDir:
--- 278,281 ----
***************
*** 357,361 ****
bForDemand = not bForDemand
! except (getopt.error, error), msg:
sys.stderr.write (str(msg) + "\n")
usage()
--- 348,352 ----
bForDemand = not bForDemand
! except (getopt.error, error) as msg:
sys.stderr.write (str(msg) + "\n")
usage()
Index: dynamic.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/dynamic.py,v
retrieving revision 1.22
retrieving revision 1.22.2.1
diff -C2 -d -r1.22 -r1.22.2.1
*** dynamic.py 26 Aug 2007 03:42:13 -0000 1.22
--- dynamic.py 29 Aug 2008 08:58:53 -0000 1.22.2.1
***************
*** 17,29 ****
"""
import traceback
- import string
- import new
-
import pythoncom
import winerror
! import build
! from types import StringType, IntType, TupleType, ListType
! from pywintypes import UnicodeType, IIDType
import win32com.client # Needed as code we eval() references it.
--- 17,27 ----
"""
import traceback
import pythoncom
import winerror
! from . import build
!
! import types
! from pywintypes import IIDType
import win32com.client # Needed as code we eval() references it.
***************
*** 56,76 ****
if debugging:
for arg in args:
! print arg,
! print
def debug_attr_print(*args):
if debugging_attr:
for arg in args:
! print arg,
! 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
def _GetGoodDispatch(IDispatch, clsctx = pythoncom.CLSCTX_SERVER):
! if type(IDispatch) in _GoodDispatchType:
try:
IDispatch = pythoncom.connect(IDispatch)
--- 54,73 ----
if debugging:
for arg in args:
! print(arg, end=' ')
! print()
def debug_attr_print(*args):
if debugging_attr:
for arg in args:
! print(arg, end=' ')
! print()
# get the type objects for IDispatch and IUnknown
dispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]
iunkType = pythoncom.TypeIIDs[pythoncom.IID_IUnknown]
_defaultDispatchItem=build.DispatchItem
def _GetGoodDispatch(IDispatch, clsctx = pythoncom.CLSCTX_SERVER):
! if isinstance(IDispatch, (str, IIDType)):
try:
IDispatch = pythoncom.connect(IDispatch)
***************
*** 86,98 ****
# 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)
--- 83,93 ----
# displayed to the user in repr() etc.
if userName is None:
! if isinstance(IDispatch, str):
userName = IDispatch
! ## elif type(IDispatch) == UnicodeType:
! ## # We always want the displayed name to be a real string
! ## userName = IDispatch.encode("ascii", "replace")
! elif not isinstance(userName, str):
!
userName = str(userName)
return (_GetGoodDispatch(IDispatch, clsctx), userName)
***************
*** 171,177 ****
allArgs = (dispid,LCID,invkind,1) + args
return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
! raise TypeError, "This dispatch object does not define a default method"
! def __nonzero__(self):
return 1 # ie "if object:" should always be "true" - without this, __len__ is tried.
# _Possibly_ want to defer to __len__ if available, but Im not sure this is
--- 166,172 ----
allArgs = (dispid,LCID,invkind,1) + args
return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
! raise TypeError("This dispatch object does not define a default method")
! def __bool__(self):
return 1 # ie "if object:" should always be "true" - without this, __len__ is tried.
# _Possibly_ want to defer to __len__ if available, but Im not sure this is
***************
*** 186,191 ****
try:
return str(self.__call__())
! except pythoncom.com_error, details:
! if details[0] not in ERRORS_BAD_CONTEXT:
raise
return self.__repr__()
--- 181,186 ----
try:
return str(self.__call__())
! except pythoncom.com_error as details:
! if details.args[0] not in ERRORS_BAD_CONTEXT:
raise
return self.__repr__()
***************
*** 203,207 ****
if invkind:
return self._oleobj_.Invoke(dispid, LCID, invkind, 1)
! raise TypeError, "This dispatch object does not define a Count method"
def _NewEnum(self):
--- 198,202 ----
if invkind:
return self._oleobj_.Invoke(dispid, LCID, invkind, 1)
! raise TypeError("This dispatch object does not define a Count method")
def _NewEnum(self):
***************
*** 211,215 ****
except pythoncom.com_error:
return None # no enumerator for this object.
! import util
return util.WrapEnum(enum, None)
--- 206,210 ----
except pythoncom.com_error:
return None # no enumerator for this object.
! from . import util
return util.WrapEnum(enum, None)
***************
*** 217,221 ****
# Improved __getitem__ courtesy Syver Enstad
# Must check _NewEnum before Item, to ensure b/w compat.
! if isinstance(index, IntType):
if self.__dict__['_enum_'] is None:
self.__dict__['_enum_'] = self._NewEnum()
--- 212,216 ----
# Improved __getitem__ courtesy Syver Enstad
# Must check _NewEnum before Item, to ensure b/w compat.
! if isinstance(index, int):
if self.__dict__['_enum_'] is None:
self.__dict__['_enum_'] = self._NewEnum()
***************
*** 226,230 ****
if invkind is not None:
return self._get_good_object_(self._oleobj_.Invoke(dispid, LCID, invkind, 1, index))
! raise TypeError, "This object does not support enumeration"
def __setitem__(self, index, *args):
--- 221,225 ----
if invkind is not None:
return self._get_good_object_(self._oleobj_.Invoke(dispid, LCID, invkind, 1, index))
! raise TypeError("This object does not support enumeration")
def __setitem__(self, index, *args):
***************
*** 238,249 ****
allArgs = (dispid,LCID,invkind,0,index) + args
return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
! raise TypeError, "This dispatch object does not define a default method"
def _find_dispatch_type_(self, methodName):
! if self._olerepr_.mapFuncs.has_key(methodName):
item = self._olerepr_.mapFuncs[methodName]
return item.desc[4], item.dispid
! if self._olerepr_.propMapGet.has_key(methodName):
item = self._olerepr_.propMapGet[methodName]
return item.desc[4], item.dispid
--- 233,244 ----
allArgs = (dispid,LCID,invkind,0,index) + args
return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
! raise TypeError("This dispatch object does not define a default method")
def _find_dispatch_type_(self, methodName):
! if methodName in self._olerepr_.mapFuncs:
item = self._olerepr_.mapFuncs[methodName]
return item.desc[4], item.dispid
! if methodName in self._olerepr_.propMapGet:
item = self._olerepr_.propMapGet[methodName]
return item.desc[4], item.dispid
***************
*** 274,281 ****
# make a new instance of (probably this) class.
return self._wrap_dispatch_(ob, userName, ReturnCLSID)
! elif self._unicode_to_string_ and UnicodeType==type(ob):
! return str(ob)
! else:
! return ob
def _get_good_object_(self,ob,userName = None, ReturnCLSID=None):
--- 269,273 ----
# make a new instance of (probably this) class.
return self._wrap_dispatch_(ob, userName, ReturnCLSID)
! return ob
def _get_good_object_(self,ob,userName = None, ReturnCLSID=None):
***************
*** 285,289 ****
if ob is None: # Quick exit!
return None
! elif type(ob)==TupleType:
return tuple(map(lambda o, s=self, oun=userName, rc=ReturnCLSID: s._get_good_single_object_(o, oun, rc), ob))
else:
--- 277,281 ----
if ob is None: # Quick exit!
return None
! elif isinstance(ob, tuple):
return tuple(map(lambda o, s=self, oun=userName, rc=ReturnCLSID: s._get_good_single_object_(o, oun, rc), ob))
else:
***************
*** 294,298 ****
methodName = build.MakePublicAttributeName(name) # translate keywords etc.
methodCodeList = self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0)
! methodCode = string.join(methodCodeList,"\n")
try:
# print "Method code for %s is:\n" % self._username_, methodCode
--- 286,290 ----
methodName = build.MakePublicAttributeName(name) # translate keywords etc.
methodCodeList = self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0)
! methodCode = "\n".join(methodCodeList)
try:
# print "Method code for %s is:\n" % self._username_, methodCode
***************
*** 304,312 ****
globNameSpace = globals().copy()
globNameSpace["Dispatch"] = win32com.client.Dispatch
! exec codeObject in globNameSpace, tempNameSpace # self.__dict__, self.__dict__
name = methodName
# Save the function in map.
fn = self._builtMethods_[name] = tempNameSpace[name]
! newMeth = new.instancemethod(fn, self, self.__class__)
return newMeth
except:
--- 296,304 ----
globNameSpace = globals().copy()
globNameSpace["Dispatch"] = win32com.client.Dispatch
! exec(codeObject, globNameSpace, tempNameSpace) # self.__dict__, self.__dict__
name = methodName
# Save the function in map.
fn = self._builtMethods_[name] = tempNameSpace[name]
! newMeth = types.MethodType(fn, self)
return newMeth
except:
***************
*** 318,322 ****
"""Cleanup object - like a close - to force cleanup when you dont
want to rely on Python's reference counting."""
! for childCont in self._mapCachedItems_.values():
childCont._Release_()
self._mapCachedItems_ = {}
--- 310,314 ----
"""Cleanup object - like a close - to force cleanup when you dont
want to rely on Python's reference counting."""
! for childCont in list(self._mapCachedItems_.values()):
childCont._Release_()
self._mapCachedItems_ = {}
***************
*** 336,357 ****
return self._get_good_object_(self._oleobj_.Invoke(*(dispId, LCID, item.desc[4], 0) + (args) ))
except KeyError:
! raise AttributeError, name
def _print_details_(self):
"Debug routine - dumps what it knows about an object."
! print "AxDispatch container",self._username_
try:
! print "Methods:"
! for method in self._olerepr_.mapFuncs.keys():
! print "\t", method
! print "Props:"
! for prop, entry in self._olerepr_.propMap.items():
! print "\t%s = 0x%x - %s" % (prop, entry.dispid, `entry`)
! print "Get Props:"
! for prop, entry in self._olerepr_.propMapGet.items():
! print "\t%s = 0x%x - %s" % (prop, entry.dispid, `entry`)
! print "Put Props:"
! for prop, entry in self._olerepr_.propMapPut.items():
! print "\t%s = 0x%x - %s" % (prop, entry.dispid, `entry`)
except:
traceback.print_exc()
--- 328,349 ----
return self._get_good_object_(self._oleobj_.Invoke(*(dispId, LCID, item.desc[4], 0) + (args) ))
except KeyError:
! raise AttributeError(name)
def _print_details_(self):
"Debug routine - dumps what it knows about an object."
! print("AxDispatch container",self._username_)
try:
! print("Methods:")
! for method in list(self._olerepr_.mapFuncs.keys()):
! print("\t", method)
! print("Props:")
! for prop, entry in list(self._olerepr_.propMap.items()):
! print("\t%s = 0x%x - %s" % (prop, entry.dispid, repr(entry)))
! print("Get Props:")
! for prop, entry in list(self._olerepr_.propMapGet.items()):
! print("\t%s = 0x%x - %s" % (prop, entry.dispid, repr(entry)))
! print("Put Props:")
! for prop, entry in list(self._olerepr_.propMapPut.items()):
! print("\t%s = 0x%x - %s" % (prop, entry.dispid, repr(entry)))
except:
traceback.print_exc()
***************
*** 428,432 ****
enum = self._oleobj_.InvokeTypes(pythoncom.DISPID_NEWENUM,LCID,invkind,(13, 10),())
except pythoncom.com_error:
! raise AttributeError, "This object can not function as an iterator"
# We must return a callable object.
class Factory:
--- 420,424 ----
enum = self._oleobj_.InvokeTypes(pythoncom.DISPID_NEWENUM,LCID,invkind,(13, 10),())
except pythoncom.com_error:
! raise AttributeError("This object can not function as an iterator")
# We must return a callable object.
class Factory:
***************
*** 439,446 ****
if attr[0]=='_' and attr[-1]=='_': # Fast-track.
! raise AttributeError, attr
# If a known method, create new instance and return.
try:
! return new.instancemethod(self._builtMethods_[attr], self, self.__class__)
except KeyError:
pass
--- 431,438 ----
if attr[0]=='_' and attr[-1]=='_': # Fast-track.
! raise AttributeError(attr)
# If a known method, create new instance and return.
try:
! return types.MethodType(self._builtMethods_[attr], self)
except KeyError:
pass
***************
*** 451,455 ****
# means we create the actual method object - which also means
# this code will never be asked for that method name again.
! if self._olerepr_.mapFuncs.has_key(attr):
return self._make_method_(attr)
--- 443,447 ----
# means we create the actual method object - which also means
# this code will never be asked for that method name again.
! if attr in self._olerepr_.mapFuncs:
return self._make_method_(attr)
***************
*** 465,469 ****
try:
if self.__LazyMap__(attr):
! if self._olerepr_.mapFuncs.has_key(attr): return self._make_method_(attr)
retEntry = self._olerepr_.propMap.get(attr)
if retEntry is None:
--- 457,461 ----
try:
if self.__LazyMap__(attr):
! if attr in self._olerepr_.mapFuncs: return self._make_method_(attr)
retEntry = self._olerepr_.propMap.get(attr)
if retEntry is None:
***************
*** 488,505 ****
try:
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
! except pythoncom.com_error, details:
if details[0] in ERRORS_BAD_CONTEXT:
# May be a method.
self._olerepr_.mapFuncs[attr] = retEntry
return self._make_method_(attr)
! raise pythoncom.com_error, details
debug_attr_print("OLE returned ", ret)
return self._get_good_object_(ret)
# no where else to look.
! raise AttributeError, "%s.%s" % (self._username_, attr)
def __setattr__(self, attr, value):
! if self.__dict__.has_key(attr): # Fast-track - if already in our dict, just make the assignment.
# XXX - should maybe check method map - if someone assigns to a method,
# it could mean something special (not sure what, tho!)
--- 480,497 ----
try:
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
! except pythoncom.com_error as details:
if details[0] in ERRORS_BAD_CONTEXT:
# May be a method.
self._olerepr_.mapFuncs[attr] = retEntry
return self._make_method_(attr)
! raise pythoncom.com_error(details)
debug_attr_print("OLE returned ", ret)
return self._get_good_object_(ret)
# no where else to look.
! raise AttributeError("%s.%s" % (self._username_, attr))
def __setattr__(self, attr, value):
! if attr in self.__dict__: # Fast-track - if already in our dict, just make the assignment.
# XXX - should maybe check method map - if someone assigns to a method,
# it could mean something special (not sure what, tho!)
***************
*** 507,515 ****
return
# Allow property assignment.
! debug_attr_print("SetAttr called for %s.%s=%s on DispatchContainer" % (self._username_, attr, `value`))
if self._olerepr_:
# Check the "general" property map.
! if self._olerepr_.propMap.has_key(attr):
entry = self._olerepr_.propMap[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
--- 499,507 ----
return
# Allow property assignment.
! debug_attr_print("SetAttr called for %s.%s=%s on DispatchContainer" % (self._username_, attr, repr(value)))
if self._olerepr_:
# Check the "general" property map.
! if attr in self._olerepr_.propMap:
entry = self._olerepr_.propMap[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
***************
*** 517,521 ****
return
# Check the specific "put" map.
! if self._olerepr_.propMapPut.has_key(attr):
entry = self._olerepr_.propMapPut[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
--- 509,513 ----
return
# Check the specific "put" map.
! if attr in self._olerepr_.propMapPut:
entry = self._olerepr_.propMapPut[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
***************
*** 527,531 ****
if self.__LazyMap__(attr):
# Check the "general" property map.
! if self._olerepr_.propMap.has_key(attr):
entry = self._olerepr_.propMap[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
--- 519,523 ----
if self.__LazyMap__(attr):
# Check the "general" property map.
! if attr in self._olerepr_.propMap:
entry = self._olerepr_.propMap[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
***************
*** 533,537 ****
return
# Check the specific "put" map.
! if self._olerepr_.propMapPut.has_key(attr):
entry = self._olerepr_.propMapPut[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
--- 525,529 ----
return
# Check the specific "put" map.
! if attr in self._olerepr_.propMapPut:
entry = self._olerepr_.propMapPut[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
***************
*** 552,554 ****
except pythoncom.com_error:
pass
! raise AttributeError, "Property '%s.%s' can not be set." % (self._username_, attr)
--- 544,546 ----
except pythoncom.com_error:
pass
! raise AttributeError("Property '%s.%s' can not be set." % (self._username_, attr))
Index: combrowse.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/combrowse.py,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -C2 -d -r1.8 -r1.8.2.1
*** combrowse.py 1 Jul 2008 01:04:40 -0000 1.8
--- combrowse.py 29 Aug 2008 08:58:52 -0000 1.8.2.1
***************
*** 15,19 ****
Details
! This module allows browsing of registered Type Libraries, COM categories,
and running COM objects. The display is similar to the Pythonwin object
browser, and displays the objects in a hierarchical window.
--- 15,19 ----
Details
! This module allows browsing of registered Type Libraries, COM categories,
and running COM objects. The display is similar to the Pythonwin object
[...1005 lines suppressed...]
! if "app" in sys.modules:
! # do it in a window
! browser.MakeTemplate()
! browser.template.OpenObject(root)
! else:
! # list=hierlist.HierListWithItems( root, win32ui.IDB_BROWSER_HIER )
! # dlg=hierlist.HierDialog("COM Browser",list)
! dlg = browser.dynamic_browser(root)
! dlg.DoModal()
if __name__=='__main__':
! main()
!
! ni = pythoncom._GetInterfaceCount()
! ng = pythoncom._GetGatewayCount()
! if ni or ng:
! print("Warning - exiting with %d/%d objects alive" % (ni,ng))
Index: util.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/util.py,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -d -r1.3 -r1.3.2.1
*** util.py 24 May 2007 13:00:03 -0000 1.3
--- util.py 29 Aug 2008 08:58:53 -0000 1.3.2.1
***************
*** 40,44 ****
def __GetIndex(self, index):
! if type(index)!=type(0): raise TypeError, "Only integer indexes are supported for enumerators"
# NOTE
# In this context, self.index is users purely as a flag to say
--- 40,44 ----
def __GetIndex(self, index):
! if type(index)!=type(0): raise TypeError("Only integer indexes are supported for enumerators")
# NOTE
# In this context, self.index is users purely as a flag to say
***************
*** 54,58 ****
if len(result):
return self._make_retval_(result[0])
! raise IndexError, "list index out of range"
def Next(self, count=1):
ret = self._oleobj_.Next(count)
--- 54,58 ----
if len(result):
return self._make_retval_(result[0])
! raise IndexError("list index out of range")
def Next(self, count=1):
ret = self._oleobj_.Next(count)
***************
*** 81,84 ****
def __iter__(self):
return self
! def next(self):
! return _get_good_object_(self._iter_.next(), resultCLSID = self.resultCLSID)
--- 81,84 ----
def __iter__(self):
return self
! def __next__(self):
! return _get_good_object_(next(self._iter_), resultCLSID = self.resultCLSID)
Index: __init__.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/__init__.py,v
retrieving revision 1.34
retrieving revision 1.34.4.1
diff -C2 -d -r1.34 -r1.34.4.1
*** __init__.py 24 May 2005 14:30:04 -0000 1.34
--- __init__.py 29 Aug 2008 08:58:52 -0000 1.34.4.1
***************
*** 6,18 ****
# dispatch object, the known class will be used. This contrasts
# with dynamic.Dispatch behaviour, where dynamic objects are always used.
! import __builtin__
# For some bizarre reason, __builtins__ fails with attribute error on __dict__ here?
! NeedUnicodeConversions = not hasattr(__builtin__, "unicode")
! import dynamic, gencache, pythoncom
import sys
import pywintypes
! from types import TupleType
! from pywintypes import UnicodeType
_PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]
--- 6,19 ----
# dispatch object, the known class will be used. This contrasts
# with dynamic.Dispatch behaviour, where dynamic objects are always used.
! import builtins
# For some bizarre reason, __builtins__ fails with attribute error on __dict__ here?
! NeedUnicodeConversions = not hasattr(builtins, "unicode")
!
! import pythoncom
! from . import dynamic, gencache
import sys
import pywintypes
!
_PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]
***************
*** 33,37 ****
pass
if resultCLSID is not None:
! import gencache
# Attempt to load generated module support
# This may load the module, and make it available
--- 34,38 ----
pass
if resultCLSID is not None:
! from . import gencache
# Attempt to load generated module support
# This may load the module, and make it available
***************
*** 66,70 ****
if (Pathname is None and Class is None) or \
(Pathname is not None and Class is not None):
! raise ValueError, "You must specify a value for Pathname or Class, but not both."
if Class is not None:
--- 67,71 ----
if (Pathname is None and Class is None) or \
(Pathname is not None and Class is not None):
! raise ValueError
if Class is not None:
***************
*** 128,136 ****
if hasattr(target, "index"): # string like
# for now, we assume makepy for this to work.
! if not ob.__class__.__dict__.has_key("CLSID"):
# Eeek - no makepy support - try and build it.
ob = gencache.EnsureDispatch(ob)
! if not ob.__class__.__dict__.has_key("CLSID"):
! raise ValueError, "Must be a makepy-able object for this to work"
clsid = ob.CLSID
# Lots of hoops to support "demand-build" - ie, generating
--- 129,137 ----
if hasattr(target, "index"): # string like
# for now, we assume makepy for this to work.
! if "CLSID" not in ob.__class__.__dict__:
# Eeek - no makepy support - try and build it.
ob = gencache.EnsureDispatch(ob)
! if "CLSID" not in ob.__class__.__dict__:
! raise ValueError
clsid = ob.CLSID
# Lots of hoops to support "demand-build" - ie, generating
***************
*** 148,153 ****
target_clsid = mod.NamesToIIDMap.get(target)
if target_clsid is None:
! raise ValueError, "The interface name '%s' does not appear in the " \
! "same library as object '%r'" % (target, ob)
mod = gencache.GetModuleForCLSID(target_clsid)
target_class = getattr(mod, target)
--- 149,153 ----
target_clsid = mod.NamesToIIDMap.get(target)
if target_clsid is None:
! raise ValueError
mod = gencache.GetModuleForCLSID(target_clsid)
target_class = getattr(mod, target)
***************
*** 155,159 ****
target_class = getattr(target_class, "default_interface", target_class)
return target_class(ob) # auto QI magic happens
! raise ValueError, "This object can not be cast"
class Constants:
--- 155,159 ----
target_class = getattr(target_class, "default_interface", target_class)
return target_class(ob) # auto QI magic happens
! raise ValueError
class Constants:
***************
*** 164,170 ****
def __getattr__(self, a):
for d in self.__dicts__:
! if d.has_key(a):
return d[a]
! raise AttributeError, a
# And create an instance.
--- 164,170 ----
def __getattr__(self, a):
for d in self.__dicts__:
! if a in d:
return d[a]
! raise AttributeError
# And create an instance.
***************
*** 252,256 ****
disp_class = gencache.GetClassForProgID(str(disp_clsid))
except pythoncom.com_error:
! raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object"
else:
disp_class = disp.__class__
--- 252,256 ----
disp_class = gencache.GetClassForP...
[truncated message content] |