Skip to content

PR: Fix debugger stop in breakpoints set on modules if stop on first line option is disabled#575

Merged
ccordoba12 merged 1 commit intospyder-ide:masterfrom
procitec:fix-spyder-22035
Feb 8, 2026
Merged

PR: Fix debugger stop in breakpoints set on modules if stop on first line option is disabled#575
ccordoba12 merged 1 commit intospyder-ide:masterfrom
procitec:fix-spyder-22035

Conversation

@rear1019
Copy link
Copy Markdown
Contributor

@rear1019 rear1019 commented Jan 30, 2026

This PR addresses spyder-ide/spyder#22025. This is not the fix we have been using internally for some time. Looking at it again I came up with a simpler and (hopefully) better fix.

The commit has a detailed explanation. It's … somewhat convoluted due to many layers being involved (Python's pdb.Pdb/bdb.Bdb and Spyder's customizations).

Please verify the fix, maybe @impact27 can give a hand. Unfortunately, I won't able to respond in the next two weeks to come.

(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] spyder-ide/spyder#22035
@ccordoba12 ccordoba12 added the type:Bug Something isn't working label Feb 2, 2026
@ccordoba12 ccordoba12 modified the milestones: v3.1.2, v3.1.3 Feb 2, 2026
@ccordoba12 ccordoba12 changed the title Fix spyder-ide/spyder#22035 PR: Fix debugger stop in breakpoints set on modules if stop on first line option is disabled Feb 2, 2026
Copy link
Copy Markdown
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your help with this @rear1019!

Note: The failure in our tests is unrelated to this and I fixed it in PR #576.

@ccordoba12 ccordoba12 merged commit 13ead33 into spyder-ide:master Feb 8, 2026
8 of 10 checks passed
@ccordoba12
Copy link
Copy Markdown
Member

@meeseeksdev please backport to 3.x

meeseeksmachine pushed a commit to meeseeksmachine/spyder-kernels that referenced this pull request Feb 8, 2026
…on modules if stop on first line option is disabled
ccordoba12 pushed a commit that referenced this pull request Feb 8, 2026
…set on modules if stop on first line option is disabled) (#578)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants