Skip to content

Commit e6b18c9

Browse files
author
Muhamed Fazal PS
committed
gh-153506: Fix IDLE crash on non-iterable __all__
When a module has __all__ set to a non-iterable value (like None), pressing Tab for module-name completion raised an uncaught TypeError. Now checks hasattr(__all__, '__iter__') before calling sorted(), falling back to the standard private-name filtering.
1 parent 0fff6bd commit e6b18c9

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/idlelib/autocomplete.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def fetch_completions(self, what, mode):
186186
bigl.extend(completion_kwds)
187187
bigl.sort()
188188
if "__all__" in bigl:
189-
smalll = sorted(eval("__all__", namespace))
189+
all_val = eval("__all__", namespace); smalll = sorted(all_val) if hasattr(all_val, "__iter__") else [s for s in bigl if s[:1] != "_"]
190190
else:
191191
smalll = [s for s in bigl if s[:1] != '_']
192192
else:
@@ -195,7 +195,7 @@ def fetch_completions(self, what, mode):
195195
bigl = dir(entity)
196196
bigl.sort()
197197
if "__all__" in bigl:
198-
smalll = sorted(entity.__all__)
198+
all_val = entity.__all__; smalll = sorted(all_val) if hasattr(all_val, "__iter__") else [s for s in bigl if s[:1] != "_"]
199199
else:
200200
smalll = [s for s in bigl if s[:1] != '_']
201201
except:

0 commit comments

Comments
 (0)