From a1242afec005398ec3a8e9640c0678e62ef4e1c4 Mon Sep 17 00:00:00 2001 From: "A. Reit" Date: Fri, 30 Jan 2026 08:58:34 +0100 Subject: [PATCH] Fix spyder-ide/spyder#22035 (See [1] for a description of the fixed issue.) Spyder's debugger is based on Python's `pdb.Pdb` debugger. The latter attempts to stop at the first line of the code when the debugger is started. This is controlled by the `Pdb._wait_for_mainpyfile` attribute and (mainly) handled by `Pdb.user_line()`. Spyder, however, attempts to continue, unless Spyder's option "Stop debugging on first line of files without breakpoints" is set and there are no breakpoints in the "main" file. The continue used to be performed By issuing a `continue` command at the input prompt when the debugger stops for the first time. This has been changed by commit `55d767704` to a direct call of `Pdb.set_continue()` and returning `False` in `Pdb.stop_here()`. This prevents a call of `Pdb.user_line()` which would have reset `Pdb._wait_for_mainpyfile`. This breaks breakpoints in dependent modules (in modules used by the main file) when Spyder's "Stop debugging on first line of files without breakpoints" is _not_ set and there are no breakpoints in the main file: Given that there are no break points in the main file, the debugger never calls `Pdb.user_line()` for the main file. For any other file `user_line()` does not reset `_wait_for_mainpyfile` because it's not in the main file. Fix the issue by resetting `_wait_for_mainpyfile` at an appropriate time. This fixes spyder-ide/spyder#22035 [1] https://github.com/spyder-ide/spyder/issues/22035 --- spyder_kernels/customize/spyderpdb.py | 1 + 1 file changed, 1 insertion(+) diff --git a/spyder_kernels/customize/spyderpdb.py b/spyder_kernels/customize/spyderpdb.py index 98ef3f52..0b2f47c1 100755 --- a/spyder_kernels/customize/spyderpdb.py +++ b/spyder_kernels/customize/spyderpdb.py @@ -287,6 +287,7 @@ def stop_here(self, frame): if self.stopframe == self.botframe and self.stoplineno == -1: return False if self.continue_if_has_breakpoints and self.should_continue(frame): + self._wait_for_mainpyfile = False self.set_continue() return False if (