summaryrefslogtreecommitdiffstats
path: root/Lib/rlcompleter.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-05-05 19:24:16 (GMT)
committerGitHub <noreply@github.com>2022-05-05 19:24:16 (GMT)
commit8122e8d5017be9f0683a49bc20d3c82e8b5398d6 (patch)
tree4072244bc4219c6cc02d5919af62b0c4aa0c96d2 /Lib/rlcompleter.py
parent1ed8d035f1edfaec34016b9f8d615df9e9fe9414 (diff)
downloadcpython-8122e8d5017be9f0683a49bc20d3c82e8b5398d6.zip
cpython-8122e8d5017be9f0683a49bc20d3c82e8b5398d6.tar.gz
cpython-8122e8d5017be9f0683a49bc20d3c82e8b5398d6.tar.bz2
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``.
Diffstat (limited to 'Lib/rlcompleter.py')
-rw-r--r--Lib/rlcompleter.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py
index 4ede6dc..206d6fb 100644
--- a/Lib/rlcompleter.py
+++ b/Lib/rlcompleter.py
@@ -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 []