python / python/cpython

Specify skip= parameters to pdb.Pdb from command line or .pdbrc

Abierto
#157,777 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

stdlib type-feature
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con el punto de entrada python -m pdb, el parámetro existente Pdb(skip=...) y el manejo de comandos de .pdbrc. Revisa la discusión enlazada en el issue y la PR gh-157780 antes de decidir el alcance. La implementación debería proporcionar una forma compatible de configurar, inspeccionar y eliminar patrones de omisión mediante la CLI y los comandos del depurador.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
cli, developer-experience
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.