Commit 80ed427
authored
Improve error handling for
* test: Expect `KeyError` for MSHTML default source interface
Add a test to verify that calling `GetEvents` on an `htmlfile` object raises a
`KeyError`.
The `IProvideClassInfo2` for this object returns a null GUID for its default
source interface. This test confirms that `comtypes` correctly fails when it
cannot find this null interface in the registry.
* feat: Handle `GUID_NULL` for outgoing interface IID in `FindOutgoingInterface`.
When `IProvideClassInfo2` returns `GUID_NULL` as the outgoing interface IID,
`FindOutgoingInterface` now raises a `NotImplementedError`. This addresses
cases where some COM servers (like `htmlfile`) return a null GUID instead
of the default source interface's GUID.
A new test case `test_retrieved_outgoing_iid_is_guid_null` has been added
to `test_eventinterface.py` to verify this behavior.
* docs: Add comment on `GUID_NULL` from `IProvideClassInfo2` in `FindOutgoingInterface`.
Adds a comment to `FindOutgoingInterface` to explain that some COM servers may
return `GUID_NULL` from `IProvideClassInfo2.GetGUID` instead of a valid
interface IID.
This clarifies the subsequent error handling for this specific edge case.
* test: Expect `AssertionError` for IMAPI2 custom event interface.
Add `Test_IMAPI2FS` to `test_eventinterface.py` to verify that `GetEvents`
raises an `AssertionError` when used with the `MsftFileSystemImage` object.
The default event interface `DFileSystemImageEvents` is a custom
`TKIND_INTERFACE` that inherits from `IDispatch`, but is neither a dual nor
pure dispatch interface. Its v-table methods, as generated from type info, lack
the `dispid` attributes that `GetEvents` requires. This test confirms the
expected failure.
* feat: Raise `NotImplementedError` for event interfaces lacking DISPIDs.
Replace `assert` in `CreateEventReceiver` with an explicit check for `dispid`,
raising `NotImplementedError` with a message when DISPIDs are missing.
* test: Rename `Test_IMAPI2FS` test and clarify DISPID requirement.
Rename `Test_IMAPI2FS.test` to `test_event_methods_lack_dispids` to better
reflect the cause of the `NotImplementedError`.GetEvents with currently unsupported COM servers. (#934)1 parent 5c416b8 commit 80ed427
2 files changed
Lines changed: 53 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
123 | 127 | | |
124 | 128 | | |
125 | 129 | | |
| |||
258 | 262 | | |
259 | 263 | | |
260 | 264 | | |
261 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
262 | 274 | | |
263 | 275 | | |
264 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
114 | 154 | | |
115 | 155 | | |
0 commit comments