Skip to content

gh-138641: Ignore set_trace() when we are already in pdb - #159918

Merged
gaogaotiantian merged 3 commits into
python:mainfrom
gaogaotiantian:nested-breakpoint
Oct 20, 2026
Merged

gaogaotiantian merged 3 commits into
python:mainfrom
gaogaotiantian:nested-breakpoint

Conversation

@gaogaotiantian

@gaogaotiantian gaogaotiantian commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

As we can't really trigger tracing functions when we are already tracing (unless we explicitly do it via sys.call_tracing), running breakpoint() / set_trace() in pdb does not make much sense. We can probably make it enter a recursive debugger in the future, but for now, ignoring it should be the simple way to go.

Notice that this is not really a breaking change as it does not work before. The nested debugger will clear the outer debugger's states and it's still the outer debugger that got triggered.

@gaogaotiantian

Copy link
Copy Markdown
Member Author

Hi @iritkatriel , could you take a look at this? This also happens to fix #142964 .

@gaogaotiantian gaogaotiantian added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 20, 2026
@gaogaotiantian
gaogaotiantian merged commit 514cfe7 into python:main Oct 20, 2026
61 checks passed
@gaogaotiantian
gaogaotiantian deleted the nested-breakpoint branch October 20, 2026 22:47
@miss-islington-app

Copy link
Copy Markdown

Thanks @gaogaotiantian for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 20, 2026

Copy link
Copy Markdown

GH-159970 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 20, 2026
@bedevere-app

bedevere-app Bot commented Oct 20, 2026

Copy link
Copy Markdown

GH-159971 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 20, 2026
gaogaotiantian added a commit that referenced this pull request Oct 21, 2026
…59918) (#159971)

gh-138641: Ignore set_trace() when we are already in pdb (GH-159918)
(cherry picked from commit 514cfe7)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
gaogaotiantian added a commit that referenced this pull request Oct 21, 2026
…59918) (#159970)

gh-138641: Ignore set_trace() when we are already in pdb (GH-159918)
(cherry picked from commit 514cfe7)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants