python / python/cpython

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

オープン
#153,506 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

@terryjreedy がすでに取り組んでいます。

2026年7月12日 から。

stdlib topic-IDLE type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。