[pywin32-checkins] pywin32/com/win32com/client __init__.py, 1.34.4.1, 1.34.4.2
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2008-08-31 09:00:12
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7525 Modified Files: Tag: py3k __init__.py Log Message: Add back some error msgs removed by 2to3 Index: __init__.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/__init__.py,v retrieving revision 1.34.4.1 retrieving revision 1.34.4.2 diff -C2 -d -r1.34.4.1 -r1.34.4.2 *** __init__.py 29 Aug 2008 08:58:52 -0000 1.34.4.1 --- __init__.py 31 Aug 2008 09:00:21 -0000 1.34.4.2 *************** *** 8,14 **** 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 --- 8,14 ---- import builtins # For some bizarre reason, __builtins__ fails with attribute error on __dict__ here? + # This can go away NeedUnicodeConversions = not hasattr(builtins, "unicode") import pythoncom from . import dynamic, gencache *************** *** 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: --- 67,71 ---- 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: *************** *** 133,137 **** 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 --- 133,137 ---- ob = gencache.EnsureDispatch(ob) if "CLSID" not in ob.__class__.__dict__: ! raise ValueError("Must be a makepy-able object for this to work") clsid = ob.CLSID # Lots of hoops to support "demand-build" - ie, generating *************** *** 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) --- 149,154 ---- 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) *************** *** 166,170 **** if a in d: return d[a] ! raise AttributeError # And create an instance. --- 167,171 ---- if a in d: return d[a] ! raise AttributeError(a) # And create an instance. *************** *** 252,256 **** disp_class = gencache.GetClassForProgID(str(disp_clsid)) except pythoncom.com_error: ! raise TypeError else: disp_class = disp.__class__ --- 253,257 ---- 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__ *************** *** 261,265 **** events_class = getevents(clsid) if events_class is None: ! raise ValueError result_class = new.classobj("COMEventClass", (disp_class, events_class, user_event_class), {"__setattr__" : _event_setattr_}) instance = result_class(disp._oleobj_) # This only calls the first base class __init__. --- 262,266 ---- events_class = getevents(clsid) if events_class is None: ! raise ValueError("This COM object does not support events.") result_class = new.classobj("COMEventClass", (disp_class, events_class, user_event_class), {"__setattr__" : _event_setattr_}) instance = result_class(disp._oleobj_) # This only calls the first base class __init__. *************** *** 304,308 **** disp_class = gencache.GetClassForProgID(str(disp_clsid)) except pythoncom.com_error: ! raise TypeError else: disp_class = disp.__class__ --- 305,309 ---- 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__ *************** *** 314,318 **** events_class = getevents(clsid) if events_class is None: ! raise ValueError result_class = new.classobj("COMEventClass", (events_class, user_event_class), {}) instance = result_class(disp) # This only calls the first base class __init__. --- 315,319 ---- events_class = getevents(clsid) if events_class is None: ! raise ValueError("This COM object does not support events.") result_class = new.classobj("COMEventClass", (events_class, user_event_class), {}) instance = result_class(disp) # This only calls the first base class __init__. *************** *** 388,391 **** --- 389,393 ---- app.MoveTo(point) """ + # XXX - to do - probably should allow "object" to already be a module object. from . import gencache object = gencache.EnsureDispatch(object) *************** *** 400,405 **** struct_guid = package.RecordMap[name] except KeyError: ! raise ValueError ! return pythoncom.GetRecordFromGuids(module.CLSID, module.MajorVersion, module.MinorVersion, module.LCID, struct_guid) --- 402,406 ---- struct_guid = package.RecordMap[name] except KeyError: ! raise ValueError("The structure '%s' is not defined in module '%s'" % (name, package)) return pythoncom.GetRecordFromGuids(module.CLSID, module.MajorVersion, module.MinorVersion, module.LCID, struct_guid) *************** *** 420,424 **** # Eg, Lotus notes. # So just let it use the existing object if E_NOINTERFACE ! if details[0] != winerror.E_NOINTERFACE: raise oobj = oobj._oleobj_ --- 421,425 ---- # Eg, Lotus notes. # So just let it use the existing object if E_NOINTERFACE ! if details.args[0] != winerror.E_NOINTERFACE: raise oobj = oobj._oleobj_ *************** *** 441,455 **** return cmp(self._oleobj_, other) ! def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, ! resultCLSID, *args): return self._get_good_object_( ! self._oleobj_.InvokeTypes( ! dispid, 0, wFlags, retType, argTypes, *args), ! user, resultCLSID) def __getattr__(self, attr): args=self._prop_map_get_.get(attr) if args is None: ! raise AttributeError return self._ApplyTypes_(*args) --- 442,454 ---- return cmp(self._oleobj_, other) ! def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args): return self._get_good_object_( ! self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), ! user, resultCLSID) def __getattr__(self, attr): args=self._prop_map_get_.get(attr) if args is None: ! raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr)) return self._ApplyTypes_(*args) *************** *** 459,463 **** args, defArgs=self._prop_map_put_[attr] except KeyError: ! raise AttributeError self._oleobj_.Invoke(*(args + (value,) + defArgs)) def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None): --- 458,462 ---- args, defArgs=self._prop_map_put_[attr] except KeyError: ! raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr)) self._oleobj_.Invoke(*(args + (value,) + defArgs)) def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None): *************** *** 494,498 **** d=self.__dict__["_dispobj_"] if d is not None: return getattr(d, attr) ! raise AttributeError def __setattr__(self, attr, value): if attr in self.__dict__: self.__dict__[attr] = value; return --- 493,497 ---- d=self.__dict__["_dispobj_"] if d is not None: return getattr(d, attr) ! raise AttributeError(attr) def __setattr__(self, attr, value): if attr in self.__dict__: self.__dict__[attr] = value; return |