|
83 | 83 | DISPATCH_PROPERTYGET, |
84 | 84 | DISPATCH_PROPERTYPUT, |
85 | 85 | DISPATCH_PROPERTYPUTREF, |
86 | | - DISPID_COLLECT, |
87 | | - DISPID_CONSTRUCTOR, |
88 | | - DISPID_DESTRUCTOR, |
89 | 86 | DISPID_EVALUATE, |
90 | 87 | DISPID_NEWENUM, |
91 | 88 | DISPID_PROPERTYPUT, |
92 | 89 | DISPID_STARTENUM, |
93 | | - DISPID_UNKNOWN, |
94 | 90 | DISPID_VALUE, |
95 | 91 | ) |
96 | 92 |
|
| 93 | +from .exception import COMException |
| 94 | + |
97 | 95 | S_OK = 0 |
98 | 96 |
|
99 | 97 | # Few more globals to speed things. |
100 | 98 | IDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch] |
101 | 99 | IUnknownType = pythoncom.TypeIIDs[pythoncom.IID_IUnknown] |
102 | 100 |
|
103 | | -from .exception import COMException |
104 | | - |
105 | | -error = __name__ + " error" |
106 | 101 |
|
107 | 102 | regSpec = "CLSID\\%s\\PythonCOM" |
108 | 103 | regPolicy = "CLSID\\%s\\PythonCOMPolicy" |
@@ -210,9 +205,8 @@ def _CreateInstance_(self, clsid, reqIID): |
210 | 205 | win32con.HKEY_CLASSES_ROOT, regSpec % clsid |
211 | 206 | ) |
212 | 207 | except win32api.error: |
213 | | - raise error( |
214 | | - "The object is not correctly registered - %s key can not be read" |
215 | | - % (regSpec % clsid) |
| 208 | + raise ValueError( |
| 209 | + f"The object is not correctly registered - {regSpec % clsid} key can not be read" |
216 | 210 | ) |
217 | 211 | myob = call_func(classSpec) |
218 | 212 | self._wrap_(myob) |
@@ -361,7 +355,7 @@ def _invokeex_(self, dispid, lcid, wFlags, args, kwargs, serviceProvider): |
361 | 355 | Simply raises an exception. |
362 | 356 | """ |
363 | 357 | # Base classes should override this method (and not call the base) |
364 | | - raise error("This class does not provide _invokeex_ semantics") |
| 358 | + raise NotImplementedError("This class does not provide _invokeex_ semantics") |
365 | 359 |
|
366 | 360 | def _DeleteMemberByName_(self, name, fdex): |
367 | 361 | return self._deletememberbyname_(name, fdex) |
@@ -515,8 +509,9 @@ def _wrap_(self, ob): |
515 | 509 | universal_data = [] |
516 | 510 | MappedWrapPolicy._wrap_(self, ob) |
517 | 511 | if not hasattr(ob, "_public_methods_") and not hasattr(ob, "_typelib_guid_"): |
518 | | - raise error( |
519 | | - "Object does not support DesignatedWrapPolicy, as it does not have either _public_methods_ or _typelib_guid_ attributes." |
| 512 | + raise ValueError( |
| 513 | + "Object does not support DesignatedWrapPolicy, " |
| 514 | + + "as it does not have either _public_methods_ or _typelib_guid_ attributes.", |
520 | 515 | ) |
521 | 516 |
|
522 | 517 | # Copy existing _dispid_to_func_ entries to _name_to_dispid_ |
@@ -732,7 +727,7 @@ class DynamicPolicy(BasicWrapPolicy): |
732 | 727 | def _wrap_(self, object): |
733 | 728 | BasicWrapPolicy._wrap_(self, object) |
734 | 729 | if not hasattr(self._obj_, "_dynamic_"): |
735 | | - raise error("Object does not support Dynamic COM Policy") |
| 730 | + raise ValueError("Object does not support Dynamic COM Policy") |
736 | 731 | self._next_dynamic_ = self._min_dynamic_ = 1000 |
737 | 732 | self._dyn_dispid_to_name_ = { |
738 | 733 | DISPID_VALUE: "_value_", |
|
0 commit comments