Specify skip= parameters to pdb.Pdb from command line or .pdbrc
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 77.2k
- Forks
- 35.9k
- Métriques de merge des PR
- Métriques de PR en attente
Description
Feature or enhancement
Proposal:
Problem
pdb.Pdb accepts a skip parameter containing glob-style module-name patterns:
pdb.Pdb(skip=["django.*", "some_package.generated.*"])
However, this existing functionality cannot be configured when invoking pdb through its command-line interface:
python -m pdb -m some_package.module
It also cannot be configured cleanly from .pdbrc. Commands from .pdbrc execute in the context of the debugged frame, and there is no documented reference to the active pdb.Pdb instance.
The current workaround requires accessing pdb implementation details:
!import sys; _pdb = sys._getframe(1).f_locals["self"]; _pdb.skip = {"some_package.*"}
This depends on the internal call stack and the local variable name used by pdb, so it is unsuitable as a supported configuration mechanism.
Proposed behavior
Expose Pdb(skip=...) through both the command-line interface and pdb commands.
For example, allow a repeatable --skip option:
python -m pdb \
--skip "django.*" \
--skip "some_package.generated.*" \
-m some_package.module
The collected patterns would be passed to the existing Pdb(skip=...) parameter.
Additionally, add a debugger command that can be used interactively, through -c, or from .pdbrc:
skip django.* some_package.generated.*
For example, .pdbrc could contain:
skip asyncio.*
skip concurrent.futures.*
Invoking the command without arguments could display the currently configured patterns:
(Pdb) skip
Skipped module patterns:
asyncio.*
concurrent.futures.*
There should also be a supported way to remove patterns, such as:
unskip asyncio.*
The exact command syntax is open to discussion. The important part is providing a supported route from the CLI and .pdbrc to the existing Pdb.skip functionality.
Standard-library convenience
A --skip-stdlib option and corresponding .pdbrc command would also be useful:
python -m pdb --skip-stdlib -m some_package.module
skip stdlib
On Python versions that provide sys.stdlib_module_names, this could be implemented using patterns for both the top-level modules and their submodules.
Standard-library skipping should remain opt-in because users may need to debug standard-library code, and an application module can shadow a standard-library module name.
Rationale
Module skipping is particularly useful when stepping through application code that calls into frameworks, generated modules, or the standard library. The underlying debugger has supported this since the addition of the skip parameter, but that capability is effectively unavailable to users of the standard python -m pdb workflow.
Exposing it would:
-
Make
Pdb(skip=...)usable from the normal pdb CLI. -
Allow project-specific skip configuration in
.pdbrc. -
Eliminate reliance on private frame and local-variable details.
-
Permit skip patterns to be inspected and changed during a debugging session.
-
Preserve the existing behavior by making all skipping opt-in.
Current workaround
For reference, the workaround currently required in .pdbrc is similar to:
!import sys; _pdb = sys._getframe(1).f_locals["self"]; _pdb.skip = (_pdb.skip or set()) | {"some_package.*"}; del _pdb
The need to reach into sys._getframe(1).f_locals to configure an already-supported Pdb option indicates that the command-line interface is missing an appropriate configuration mechanism.
Skipping stdlib through .pdbrc
!import sys; _pdb = sys._getframe(1).f_locals\["self"\]; _pdb.skip = (_pdb.skip or set()) | {"click.\*"} | {p for n in sys.stdlib_module_names for p in (n, n + ".*")}; del _pdb;
Why not use IPython’s debugger, an IDE, or another debugger?
Third-party debuggers and IDE integrations may provide similar stepping filters or more extensive configuration. However, they are not always available in the environments where pdb is most valuable.
My primary development environment is an air-gapped system. It currently uses Python 3.10 and is expected to move to Python 3.14, but upgrades are irregular and installing an additional debugger package is not always possible. Every additional dependency must be acquired, reviewed, approved, transferred, and maintained within the isolated environment.
I also frequently work through SSH, including on remote systems where a graphical IDE or its remote-debugging integration is unavailable or impractical. In these situations, the standard-library pdb CLI is the most portable and consistently available debugger:
python -m pdb -m package.module
This proposal does not attempt to reproduce the broader functionality of IPython, ipdb, IDE debuggers, or other third-party tools. It exposes functionality that pdb.Pdb already implements through the standard python -m pdb interface. Users should not need an additional package or graphical development environment merely to supply the existing skip= parameter.
Disclosure: I used an AI assistant to help draft and organize this feature proposal. I reviewed and edited the resulting text, and the proposal reflects the behavior and use case I encountered.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
https://discuss.python.org/t/specify-skip-parameters-to-pdb-pdb-from-command-line-or-pdbrc/109042/3
Linked PRs
- gh-157780
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par le point d’entrée python -m pdb, le paramètre existant Pdb(skip=...) et la gestion des commandes de .pdbrc. Examinez la discussion liée dans l’issue et la PR gh-157780 avant de décider de la portée. La fonctionnalité terminée devrait fournir un moyen pris en charge de configurer, d’inspecter et de supprimer des motifs d’exclusion via la CLI et les commandes du débogueur.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- cli, developer-experience
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 25/100