python / python/cpython

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

Aberta
#157,777 3 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

stdlib type-feature
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece pelo ponto de entrada python -m pdb, pelo parâmetro existente Pdb(skip=...) e pelo tratamento de comandos do .pdbrc. Revise a discussão vinculada na issue e o PR gh-157780 antes de decidir o escopo. A implementação concluída deve fornecer uma maneira compatível de configurar, inspecionar e remover padrões de skip por meio da CLI e dos comandos do debugger.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
cli, developer-experience
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.