mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-92345: Import rlcompleter before sys.path is extended (#92346)
``pymain_run_python()`` now imports ``readline`` and ``rlcompleter`` before sys.path is extended to include the current working directory of an interactive interpreter. Non-interactive interpreters are not affected. Also move imports of ``re`` and ``keyword`` module to top level so they are materialized early, too. The ``keyword`` module is trivial and the ``re`` is already imported via ``inspect`` -> ``linecache``.
This commit is contained in:
parent
1ed8d035f1
commit
8122e8d501
3 changed files with 15 additions and 3 deletions
|
@ -32,6 +32,8 @@ Notes:
|
|||
import atexit
|
||||
import builtins
|
||||
import inspect
|
||||
import keyword
|
||||
import re
|
||||
import __main__
|
||||
|
||||
__all__ = ["Completer"]
|
||||
|
@ -113,7 +115,6 @@ class Completer:
|
|||
defined in self.namespace that match.
|
||||
|
||||
"""
|
||||
import keyword
|
||||
matches = []
|
||||
seen = {"__builtins__"}
|
||||
n = len(text)
|
||||
|
@ -146,7 +147,6 @@ class Completer:
|
|||
with a __getattr__ hook is evaluated.
|
||||
|
||||
"""
|
||||
import re
|
||||
m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text)
|
||||
if not m:
|
||||
return []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue