diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-07-15 22:49:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-15 22:49:41 (GMT) |
commit | 5b718e7fc723d484951aa76abd176aadcd0d1518 (patch) | |
tree | dd3306e9fc52d3701f96cf185da2a7f0451267a9 /Lib/_pyrepl/readline.py | |
parent | 0794220a6935a25bd9667be60b0c67403bc73f47 (diff) | |
download | cpython-5b718e7fc723d484951aa76abd176aadcd0d1518.zip cpython-5b718e7fc723d484951aa76abd176aadcd0d1518.tar.gz cpython-5b718e7fc723d484951aa76abd176aadcd0d1518.tar.bz2 |
[3.13] gh-121790: Fix interactive console initialization (GH-121793) (GH-121822)
(cherry picked from commit e5c7216f376a06d2c931daf999e2980e494e747e)
Co-authored-by: Milan Oberkirch <milan.oberkirch@geops.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/_pyrepl/readline.py')
-rw-r--r-- | Lib/_pyrepl/readline.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/_pyrepl/readline.py b/Lib/_pyrepl/readline.py index 28f592d..3d94f91 100644 --- a/Lib/_pyrepl/readline.py +++ b/Lib/_pyrepl/readline.py @@ -58,7 +58,7 @@ from .types import Callback, Completer, KeySpec, CommandName TYPE_CHECKING = False if TYPE_CHECKING: - from typing import Any + from typing import Any, Mapping MoreLinesCallable = Callable[[str], bool] @@ -559,7 +559,7 @@ for _name, _ret in [ # ____________________________________________________________ -def _setup(namespace: dict[str, Any]) -> None: +def _setup(namespace: Mapping[str, Any]) -> None: global raw_input if raw_input is not None: return # don't run _setup twice @@ -575,7 +575,9 @@ def _setup(namespace: dict[str, Any]) -> None: _wrapper.f_in = f_in _wrapper.f_out = f_out - # set up namespace in rlcompleter + # set up namespace in rlcompleter, which requires it to be a bona fide dict + if not isinstance(namespace, dict): + namespace = dict(namespace) _wrapper.config.readline_completer = RLCompleter(namespace).complete # this is not really what readline.c does. Better than nothing I guess |