GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-82987: Stop on calling frame unconditionally for inline breakpoints by gaogaotiantian · Pull Request #130493 · python/cpython

Conversation

@gaogaotiantian

@gaogaotiantian gaogaotiantian commented Feb 24, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

The testing code

import pdb
def foo():
    x = 40 + 2
    pdb.Pdb(skip=['__main__']).set_trace()
foo()

seems a bit silly, but this is a real issue because we use the last instance of pdb for inline breakpoints now.

So if we instantiate a debugger like p = pdb.Pdb(skip=["django.*"]) somewhere, and we set an inline breakpoint in Django with an innocent breakpoint(), it still won't stop inside Django modules.

Overall I think it's reasonable that we always stop for inline breakpoints. The implementation I chose is to remove the condition for opcode events which also makes sense. For now that event is exclusively used by inline breakpoints. Even if we add instruction level debugging in the future, I think the only useful command is "step instruction". It's hard to imagine instruction level breakpoints or something like until instruction. Always trigger user function for opcode seems like an okay solution.

  • Issue: "pdb.Pdb(skip=…).set_trace()" should always stop on calling frame #82987

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gaogaotiantian
Stop on calling frame unconditionally for inline breakpoints
37b3d29
@gaogaotiantian
gaogaotiantian requested a review from iritkatriel February 24, 2025 01:47
@bedevere-app bedevere-app Bot added the awaiting core review label Feb 24, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Feb 24, 2025
"pdb.Pdb(skip=…).set_trace()" should always stop on calling frame #82987
Closed
@blurb-it
📜🤖 Added by blurb_it.
6716ac0
tomasr8
tomasr8 reviewed Feb 24, 2025
View reviewed changes
Comment thread Lib/bdb.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@gaogaotiantian @tomasr8
Update Lib/bdb.py
c6947d1
Co-authored-by: Tomas R. <[email protected]>
iritkatriel
iritkatriel reviewed Mar 3, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2025-02-24-01-49-11.gh-issue-82987.vHfQlG.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/NEWS.d/next/Library/2025-02-24-01-49-11.gh-issue-82987.vHfQlG.rst Outdated
@@ -0,0 +1 @@
:mod:`pdb` will always stop on calling frames when inline breakpoints like :func:`breakpoint` or :func:`pdb.set_trace` are used, regardless of whether the module matches ``skip`` pattern.

@iritkatriel iritkatriel Mar 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is probably worth a what's new entry.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iritkatriel iritkatriel Mar 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

And a versionchange comment in the doc?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gaogaotiantian gaogaotiantian Mar 3, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gaogaotiantian and others added 2 commits March 3, 2025 17:37
@gaogaotiantian @iritkatriel
Update Misc/NEWS.d/next/Library/2025-02-24-01-49-11.gh-issue-82987.vH…
e8c7d66
…fQlG.rst

Co-authored-by: Irit Katriel <[email protected]>
@gaogaotiantian
Add version change in pdb and add whatsnew entry
2cda74c
iritkatriel
iritkatriel reviewed Mar 3, 2025
View reviewed changes
Comment thread Doc/library/pdb.rst Outdated
Added the *mode* argument.

.. versionchanged:: 3.14
*skip* will be ignored if inline breakpoints like :func:`breakpoint` or :func:`set_trace` are used.

@iritkatriel iritkatriel Mar 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

"if ... are used" could be misunderstood to mean that skip will always be ignored if those are ever used.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gaogaotiantian gaogaotiantian Mar 3, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Will changing it to "when ... are used" better? Or we should just use the longer version from the news entry?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iritkatriel iritkatriel Mar 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think "when .. are used" has the same problem, as does the longer version from the news entry.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gaogaotiantian gaogaotiantian Mar 3, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Inline breakpoints like :func:`breakpoint` or :func:`pdb.set_trace` will always stop the program at calling frame, ignoring the ``skip`` pattern (if any).

Is this better?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iritkatriel iritkatriel Mar 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gaogaotiantian gaogaotiantian Mar 4, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Then I'll use this for all 3 places :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gaogaotiantian
Update description
418e7b1
iritkatriel
iritkatriel approved these changes Mar 4, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Mar 4, 2025
@gaogaotiantian
gaogaotiantian merged commit 63b6ec3 into python:main Mar 4, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 4, 2025
@gaogaotiantian
gaogaotiantian deleted the breakpoint-stop-unconditionally branch March 4, 2025 16:58
@gaogaotiantian gaogaotiantian mentioned this pull request Oct 9, 2025
Add ignore_module/unignore_module commands to pdb #139721
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@tomasr8 tomasr8 tomasr8 left review comments
@iritkatriel iritkatriel iritkatriel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@gaogaotiantian @iritkatriel @tomasr8
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.