Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove todo comment
  • Loading branch information
tomasr8 committed Apr 19, 2025
commit 7a2fde06e0b5cb9310b1947e0f449b2e22a0d39d
3 changes: 2 additions & 1 deletion Lib/_pyrepl/readline.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def get_completions(self, stem: str) -> list[str]:
return result

def get_module_completions(self) -> list[str]:
completer = ModuleCompleter(namespace={'__package__': '_pyrepl'}) # TODO: namespace?
# Inside pyrepl, __package__ is set to '_pyrepl'
completer = ModuleCompleter(namespace={'__package__': '_pyrepl'})
line = self.get_line()
return completer.get_completions(line)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this raise? What do we want to do if any of the pkgutil raises for any reason?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't unless iter_modules or find_spec raise. Since those can call code from user-supplied finders, they can raise an arbitrary exception. I could add a simple except Exception block and simply return no completions if that happens. To the user it would look like no completions are available rather than outright crashing the repl.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in fd81999


Expand Down