python / python/cpython

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

Ouverte
#153,506 1 commentaire 0 réactions 1 personne assignée Voir sur GitHub

@terryjreedy y travaille déjà.

Depuis le 12/7/2026.

stdlib topic-IDLE type-bug
Langage dominant
Python
Étoiles
77.2k
Forks
35.9k
Métriques de merge des PR
Métriques de PR en attente

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.