gh-125140: Remove the current directory from sys.path when using pyrepl (GH-125212)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
parent
1877543d03
commit
c7d5d1d93b
11
Lib/site.py
11
Lib/site.py
@ -503,9 +503,14 @@ def register_readline():
|
|||||||
if PYTHON_BASIC_REPL:
|
if PYTHON_BASIC_REPL:
|
||||||
CAN_USE_PYREPL = False
|
CAN_USE_PYREPL = False
|
||||||
else:
|
else:
|
||||||
import _pyrepl.readline
|
original_path = sys.path
|
||||||
import _pyrepl.unix_console
|
sys.path = [p for p in original_path if p != '']
|
||||||
from _pyrepl.main import CAN_USE_PYREPL
|
try:
|
||||||
|
import _pyrepl.readline
|
||||||
|
import _pyrepl.unix_console
|
||||||
|
from _pyrepl.main import CAN_USE_PYREPL
|
||||||
|
finally:
|
||||||
|
sys.path = original_path
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
Remove the current directory from ``sys.path`` when using PyREPL.
|
Loading…
x
Reference in New Issue
Block a user