Closed CristiFati closed 4 months ago
I quite like these semantics, but I'm not clear on the b/w compat story. Although you added this as an "option", each call site is what determines this option.
In other words, I'd like to understand how your tests change if you do not ever specify that new bool.
I think that design-wise the correct behavior would be to always return None when there is no error (like calling the function with the (extra) bool set to true). But I am afraid that there is code relying on the fact that an exception is raised even if GetLastError returns 0, so I took the safe side, and I just added support for this behavior, because I think that changing it altogether might break some (external) things. As code is right now, nothing changes in all places that call PyWin_SetAPIError. If you think that changing default behavior wouldn't be a problem I can change that bool's default value (or remove it altogether (keeping the new behavior)).
Closing, as it was replaced by the 2 linked PRs.
This is a (proposed) fix for #2163. If the user wants to stop iteration (by returning FALSE (or equivalent) from the callback) EnumWindows (&& friends) should not raise exception. It should only raise exception if callback:
Notes:
PyWin_SetAPIError: considering that 0 (SUCCESS) is Win's way of signaling non failure, I think that (logically) this should be the default behavior (if there's no error, don't raise any exception, especially since that message is not clear). But:
I only added this behavior as an option (disabled by default)
IMPORTANT - do not merge until next question is answered: