Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import rlcompleter before sys.path is extended #92345

Closed
tiran opened this issue May 5, 2022 · 1 comment
Closed

Import rlcompleter before sys.path is extended #92345

tiran opened this issue May 5, 2022 · 1 comment
Labels
type-feature A feature request or enhancement

Comments

@tiran
Copy link
Member

tiran commented May 5, 2022

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.

@tiran tiran added the type-feature A feature request or enhancement label May 5, 2022
tiran added a commit to tiran/cpython that referenced this issue May 5, 2022
``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>
tiran added a commit that referenced this issue May 5, 2022
``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``.
@erlend-aasland
Copy link
Contributor

erlend-aasland commented May 16, 2022

Looks like #92346 fixed this. Can we close this?

@erlend-aasland erlend-aasland added the pending The issue will be closed if no feedback is provided label May 16, 2022
@tiran tiran closed this as completed May 17, 2022
@AA-Turner AA-Turner removed the pending The issue will be closed if no feedback is provided label May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants