From 4b295ef0bda8e4a3afacd4e2411f72e0cb8d7464 Mon Sep 17 00:00:00 2001 From: Simon Robinson Date: Tue, 2 Aug 2022 15:15:02 +0100 Subject: [PATCH] Catch AttributeError as well as KeyError `ChangeWindowMessageFilterEx` is not always present on Win32 variants. Win32.py already handles this, but catches only `KeyError`. I haven't seen this exception, but I have encountered `AttributeError`, which should be caught as well to avoid a crash. --- lib/pystray/_util/win32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pystray/_util/win32.py b/lib/pystray/_util/win32.py index c053e9d..e9a8f23 100644 --- a/lib/pystray/_util/win32.py +++ b/lib/pystray/_util/win32.py @@ -346,7 +346,7 @@ def _err(result, func, arguments): ChangeWindowMessageFilterEx.restype = wintypes.BOOL ChangeWindowMessageFilterEx.errcheck = _err -except KeyError: +except (KeyError, AttributeError): def ChangeWindowMessageFilterEx( hWnd, message, action, pCHangeFilterStruct): """A dummy implementation of ``ChangeWindowMessageFilterEx`` always