Skip to content

Commit 5643a8c

Browse files
committed
gh-125140: Remove the current directory from sys.path when using pyrepl
1 parent f2cb399 commit 5643a8c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Lib/site.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,15 +497,19 @@ def register_readline():
497497
PYTHON_BASIC_REPL = False
498498

499499
import atexit
500+
import sys
500501
try:
501502
import readline
502503
import rlcompleter # noqa: F401
503504
if PYTHON_BASIC_REPL:
504505
CAN_USE_PYREPL = False
505506
else:
507+
original_path = sys.path
508+
sys.path = [p for p in original_path if p != '']
506509
import _pyrepl.readline
507510
import _pyrepl.unix_console
508511
from _pyrepl.main import CAN_USE_PYREPL
512+
sys.path = original_path
509513
except ImportError:
510514
return
511515

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove the current directory from sys.path when using pyrepl

0 commit comments

Comments
 (0)