FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-139721: Add ignore_module/unignore_module commands to pdb by ktowen · Pull Request #139724 · python/cpython · GitHub

/ cpython Public

gh-139721: Add ignore_module/unignore_module commands to pdb - #139724

Closed
ktowen wants to merge 3 commits into
python:mainfrom
ktowen:feature/pdb-ignore-modules
Closed

gh-139721: Add ignore_module/unignore_module commands to pdb#139724
ktowen wants to merge 3 commits into
python:mainfrom
ktowen:feature/pdb-ignore-modules

Conversation

ktowen commented Oct 7, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown

Add two new commands to pdb for skipping frames from specified modules:

  • ignore_module [module_name]: Add modules to skip during debugging
  • unignore_module [module_name]: Remove modules from skip list

When a module is ignored, the debugger automatically skips over its frames during step, next, continue, up, and down commands. Supports wildcard patterns via fnmatch for flexible module matching.

This feature improves debugging productivity when working with frameworks by allowing developers to hide framework-internal frames and focus on application code.

Issue: #139721

python-cla-bot Bot commented Oct 7, 2025
edited
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

ktowen added 3 commits October 8, 2025 08:40
Add two new commands to pdb for skipping frames from specified modules:
- ignore_module [module_name]: Add modules to skip during debugging
- unignore_module [module_name]: Remove modules from skip list

When a module is ignored, the debugger automatically skips over its
frames during step, next, continue, up, and down commands. Supports
wildcard patterns via fnmatch for flexible submodule matching.
Fix pdbcmd_sig_re to include underscores for commands like ignore_module
ktowen force-pushed the feature/pdb-ignore-modules branch from 401e1e3 to e3d97d0 Compare October 8, 2025 06:47
ktowen marked this pull request as ready for review October 8, 2025 12:32

picnixz left a comment
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't really like the "unignore" verb (but I don't have a really better suggestion). How about ignore-module X on/off. Or "[show/hide]-module-frames"? (though you need to write more characters, but you can use autocompletion otherwise).

# Support for documenting pdb commands

pdbcmd_sig_re = re.compile(r'([a-z()!]+)\s*(.*)')
pdbcmd_sig_re = re.compile(r'([a-z()!_]+)\s*(.*)')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Commands usually have dashes instead of underscores. At least most UNIX commands would be with dashes so I think it's better to have dashes in general. (also gdb uses dashes and not underscores for commands with multiple words)

ktowen Oct 11, 2025
edited
Loading

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I tried to follow the convention of using snake case, the other option I was thinking is not using separator as pdb does with the commands longlist, whatis and retval. Adding dashes will imply changing how the commands are defined and discovered.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

For CLI-like options, I would prefer using dashes. Those are not really variables (even though they are stored in variables in the end). I'll leave the decision to Tian but we could also consider not having dashes/underscores at all if we find better words (showmodule, hidemodule would be fine I think although we're not really hiding them per se, just hiding them in the traceback).

Comment thread Lib/test/test_pdb.py
> <doctest test.test_pdb.test_pdb_skip_modules_with_callback[0]>(5)skip_module()
-> mod.foo_pony(callback)
(Pdb) step
[... skipped 1 ignored module(s)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

May I know why we have an ignored module here although the test uses the default parameters?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There is an skipped module in the Pdb initialization

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ah I see, it wasn't part of the diff. If we already have skip=... to parametrize this, I would suggest that we use skipmodule and unskipmodule for the commands instead.

Comment thread Lib/pdb.py

newframe = i
if module_skipped:
self.message(f'[... skipped {module_skipped} frame(s) '

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I would suggest indicating which module was ignored if there is only 1 module being ignored.

Comment thread Lib/pdb.py
try:
self.skip.remove(module_name)
self.message(f'No longer ignoring module: {module_name}')
except KeyError:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This should only be emitted after .remove was called (in case .message raises a KeyError for some obscure reasons)

@@ -0,0 +1,5 @@
Add ``ignore_module`` and ``unignore_module`` commands to :mod:`pdb` to

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This would also need a What's New entry because it's a new feature for 3.15.

Comment thread Doc/library/pdb.rst
- Skip standard library modules (``threading``, ``multiprocessing``, ``logging.*``)
- Skip test framework internals (``*pytest*``, ``unittest.*``)

.. versionadded:: 3.15

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
.. versionadded:: 3.15
.. versionadded:: next

hugovk removed their request for review October 8, 2025 13:00

ktowen commented Oct 11, 2025

Copy link
Copy Markdown
Author

I don't really like the "unignore" verb (but I don't have a really better suggestion). How about ignore-module X on/off. Or "[show/hide]-module-frames"? (though you need to write more characters, but you can use autocompletion otherwise).

I'm not a big fan of that verb either but I tried to keep the functionality and naming consistent with other "oposite" commands like alias/unalias and display/undisplay

Copy link
Copy Markdown
Member

I'd prefer the hide-module-frames form, it's immediately clearer on what it does (unlike ignore-module), and the antonym form is better too.

A

AA-Turner requested review from Copilot and removed request for AA-Turner and Copilot October 11, 2025 12:46

Copy link
Copy Markdown
Member

Please take a look at my comment #139721 (comment) before spending more time on this feature. Thanks!

ktowen commented Oct 23, 2025

Copy link
Copy Markdown
Author

Thank you all for the comments. Following @gaogaotiantian suggestion I will close this PR and seek more feedback/support for this feature

ktowen closed this Oct 23, 2025
ktowen deleted the feature/pdb-ignore-modules branch October 23, 2025 16:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL