diff --git a/Lib/idlelib/autocomplete.py b/Lib/idlelib/autocomplete.py index 032d31225315fb..b07e10ac24e46b 100644 --- a/Lib/idlelib/autocomplete.py +++ b/Lib/idlelib/autocomplete.py @@ -186,7 +186,8 @@ def fetch_completions(self, what, mode): bigl.extend(completion_kwds) bigl.sort() if "__all__" in bigl: - smalll = sorted(eval("__all__", namespace)) + all_val = eval("__all__", namespace) + smalll = sorted(all_val) if hasattr(all_val, "__iter__") else [s for s in bigl if s[:1] != "_"] else: smalll = [s for s in bigl if s[:1] != '_'] else: @@ -195,7 +196,8 @@ def fetch_completions(self, what, mode): bigl = dir(entity) bigl.sort() if "__all__" in bigl: - smalll = sorted(entity.__all__) + all_val = entity.__all__ + smalll = sorted(all_val) if hasattr(all_val, "__iter__") else [s for s in bigl if s[:1] != "_"] else: smalll = [s for s in bigl if s[:1] != '_'] except: diff --git a/Misc/NEWS.d/next/IDLE/2026-07-11-00-00-00.gh-issue-153506.xYzAbC.rst b/Misc/NEWS.d/next/IDLE/2026-07-11-00-00-00.gh-issue-153506.xYzAbC.rst new file mode 100644 index 00000000000000..90b9d7716b45de --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2026-07-11-00-00-00.gh-issue-153506.xYzAbC.rst @@ -0,0 +1,3 @@ +Fix IDLE shell crash when Tab-completing in a module with a non-iterable +``__all__`` attribute (e.g. ``__all__ = None``). The shell now falls back +to standard completion instead of raising :exc:`TypeError`.