Python should import rlcompleter module with readline module before sys.path gets extended. This prevents accidentally shadowing of readline and rlcompleter modules when the current working directory contains a Python file with the same name.
The text was updated successfully, but these errors were encountered:
``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``.
Signed-off-by: Christian Heimes <christian@python.org>
``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``.
tiran commentedMay 5, 2022
Python should import
rlcompleter
module withreadline
module beforesys.path
gets extended. This prevents accidentally shadowing ofreadline
andrlcompleter
modules when the current working directory contains a Python file with the same name.The text was updated successfully, but these errors were encountered: