Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.4.02, 2026/06/16 -- ALL: Fixed WatchDog.stop() not joining the worker thread. Known to have been causing Xlib race conditions on Linux
0.4.02, 2026/06/16 -- ALL: Replaced bare `except:` clauses with `except Exception:`, preventing accidental suppression of system-exit signals (KeyboardInterrupt, SystemExit) during error handling.
ALL: Fixed WatchDog.stop() not joining the worker thread. Known to have been causing Xlib race conditions on Linux
0.4.01, 2024/09/22 -- ALL: Added getAllWindowsDict() general function. Added getPID() method.
LINUX: Added bad window filter to check for window.id == 0
0.4, 2023/10/11 -- ALL: Added getMonitor() as alias for getDisplay()
Expand Down
6 changes: 3 additions & 3 deletions src/pywinctl/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def isAlive(self):
"""
try:
alive = bool(self._watchdog and self._watchdog.is_alive())
except:
except Exception:
alive = False
return alive

Expand Down Expand Up @@ -663,7 +663,7 @@ def _getInitialValues(self):

if self._changedDisplayCB:
self._display = self._win.getDisplay()
except:
except Exception:
if self._isAliveCB:
self._isAliveCB(False)
self.kill()
Expand Down Expand Up @@ -744,7 +744,7 @@ def run(self):
if self._display != display:
self._display = display
self._changedDisplayCB(display)
except:
except Exception:
if self._isAliveCB:
self._isAliveCB(False)
self.kill()
Expand Down
2 changes: 1 addition & 1 deletion src/pywinctl/_pywinctl_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def __remove_bad_windows(windows: Optional[Union[List[str], List[int]]]) -> List
try:
# Thanks to Seraphli (https://github.com/Seraphli) for pointing out this issue!
if window: outList.append(LinuxWindow(window))
except:
except Exception:
pass
return outList

Expand Down
14 changes: 7 additions & 7 deletions src/pywinctl/_pywinctl_macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def getAllWindows() -> List[MacOSWindow]:
try:
pID = item[0]
title = item[1]
except:
except Exception:
continue
for activeApp in activeApps:
if activeApp.processIdentifier() == pID:
Expand Down Expand Up @@ -463,10 +463,10 @@ def _getWindowTitles() -> List[List[str]]:
pos = res[1][1][i][j]
size = res[1][2][i][j]
result.append([pID, title, pos, size])
except:
except Exception:
pass
j += 1
except:
except Exception:
pass
return result

Expand Down Expand Up @@ -1852,19 +1852,19 @@ def _getaccesskey(self, item_info: Union[Dict[str, Dict[str, str]], Dict[str, _I

try:
key = item_info["AXMenuItemCmdChar"]["value"]
except:
except Exception:
key = ""
try:
modifiers = int(item_info["AXMenuItemCmdModifiers"]["value"])
except:
except Exception:
modifiers = -1
try:
glyph = int(item_info["AXMenuItemCmdGlyph"]["value"])
except:
except Exception:
glyph = -1
try:
virtual_key = int(item_info["AXMenuItemCmdVirtualKey"]["value"])
except:
except Exception:
virtual_key = -1

modifiers_type = ""
Expand Down
12 changes: 6 additions & 6 deletions src/pywinctl/_pywinctl_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __remove_bad_windows(windows: Optional[List[int]]):
for window in windows:
try:
outList.append(Win32Window(window))
except:
except Exception:
pass
return outList

Expand Down Expand Up @@ -459,7 +459,7 @@ def _getWindowInfo(hWnd: Optional[Union[int, str, bytes, bool]]) -> tagWINDOWINF
wi.cbSize = ctypes.sizeof(wi)
try:
ctypes.windll.user32.GetWindowInfo(hWnd, ctypes.byref(wi))
except:
except Exception:
pass

# None of these seem to return the right value, at least not in my system, but might be useful for other metrics
Expand Down Expand Up @@ -520,7 +520,7 @@ def getExtraFrameSize(self, includeBorder: bool = True) -> Tuple[int, int, int,
try:
xBorder = ctypes.windll.user32.GetSystemMetrics(win32con.SM_CXBORDER)
yBorder = ctypes.windll.user32.GetSystemMetrics(win32con.SM_CYBORDER)
except:
except Exception:
xBorder = 1
yBorder = 1
xOffset -= xBorder
Expand Down Expand Up @@ -643,7 +643,7 @@ def activate(self, wait: bool = False, user: bool = True) -> bool:
"""
try:
win32gui.SetForegroundWindow(self._hWnd)
except:
except Exception:
pass
return self.isActive

Expand Down Expand Up @@ -1017,7 +1017,7 @@ def isAlive(self) -> bool:
# desc: str = win32api.GetFileVersionInfo(exeName, stringFileInfo) # type: ignore[func-returns-value]
# if desc:
# description = desc
# except:
# except Exception:
# pass
# return description
#
Expand All @@ -1038,7 +1038,7 @@ def isAlive(self) -> bool:
# w: pywinauto.WindowSpecification = sysTray.child_window(title_re=name, found_index=0)
# ret: Rect = w.rectangle()
# return Rect(ret.left, ret.top, ret.right, ret.bottom)
# except:
# except Exception:
# return None
#
# def _intToRGBA(color: int) -> Tuple[int, int, int, int]:
Expand Down