From f01d67f2943b46f7f3c05569853f7e21ef2d0d4d Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 13 Oct 2024 14:01:12 -0400 Subject: [PATCH] Fix last reportUndefinedVariable error (#2326) --- CHANGES.txt | 1 + Pythonwin/pywin/debugger/debugger.py | 13 ++++++------- pyrightconfig.json | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 84b8d5906..0e7a52654 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -16,6 +16,7 @@ Coming in build 309, as yet unreleased * Improved handling of dict iterations and fallbacks (removes Python 2 support code, small general speed improvement) (#2332, #2330, @Avasam) * Fixed "Open GL Demo" (`Pythonwin/pywin/Demos/openGLDemo.py`) and restore "Font" demo in `Pythonwin/pywin/Demos/guidemo.py` (#2345, @Avasam) +* Fixed accidentally trying to raise an undefined name instead of an `Exception` in `Pythonwin/pywin/debugger/debugger.py` (#2326, @Avasam) Build 308, released 2024-10-12 ------------------------------ diff --git a/Pythonwin/pywin/debugger/debugger.py b/Pythonwin/pywin/debugger/debugger.py index dca59b8c7..72b9cf2dc 100644 --- a/Pythonwin/pywin/debugger/debugger.py +++ b/Pythonwin/pywin/debugger/debugger.py @@ -869,15 +869,14 @@ def RespondDebuggerState(self, state): elif state == DBGSTATE_RUNNING: # Code is running under the debugger. title = " - running" elif state == DBGSTATE_BREAK: # We are at a breakpoint or stepping or whatever. - if self.bAtException: - if self.bAtPostMortem: - title = " - post mortem exception" - else: - title = " - exception" - else: + if not self.bAtException: title = " - break" + elif self.bAtPostMortem: + title = " - post mortem exception" + else: + title = " - exception" else: - raise error("Invalid debugger state passed!") + raise ValueError("Invalid debugger state passed!") win32ui.GetMainFrame().SetWindowText( win32ui.LoadString(win32ui.IDR_MAINFRAME) + title ) diff --git a/pyrightconfig.json b/pyrightconfig.json index d90035dc3..1721da1a2 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -39,9 +39,8 @@ "reportOptionalSubscript": "warning", // Needs fixes in types-pywin32 and requires Python 3.8 to annotate ambiguous global variables "reportUnnecessaryComparison": "warning", - // TODO: Leave Unbound/Undefined to their own PR(s) + // TODO: Leave Unbound its own PR(s) "reportUnboundVariable": "warning", - "reportUndefinedVariable": "warning", // Too many dynamically generated modules. This will require type stubs to properly fix. "reportMissingImports": "warning", // IDEM, but happens when pywin32 is not in site-packages but module is found from typeshed.