python / python/cpython

IDLE module-name completion crashes on a non-iterable __all__

Aperta
#153,506 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@terryjreedy ci sta già lavorando.

Dal 12/7/2026.

stdlib topic-IDLE type-bug
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug report

Bug description:

When the IDLE shell namespace has a non-iterable __all__ (for example __all__ = None, an easy typo), pressing Tab for module-name completion at an empty prefix raises an uncaught TypeError instead of showing completions.

autocomplete.AutoComplete.fetch_completions handles the ATTRS empty-prefix case with sorted(eval("__all__", namespace)) and no guard, while the sibling non-empty-prefix branch already wraps the equivalent sorted(entity.__all__) in try/except and returns empty lists on failure. Only the empty-prefix branch is affected.

Reproduction in the IDLE shell:

>>> __all__ = None
>>> # press Tab at an empty prefix
TypeError: 'NoneType' object is not iterable

A deterministic regression test that drives fetch_completions with a patched __main__.__all__ is included in the linked PR.

Suggested fix: guard the empty-prefix branch the same way the sibling branch is guarded, returning empty completion lists when __all__ cannot be evaluated or sorted.

CPython versions tested on:

3.16, CPython main branch

Operating systems tested on:

macOS

Linked PRs
  • gh-153507
  • gh-153527

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.