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:
Pablo Galindo Salgado 2024-10-09 23:30:56 +01:00 committed by GitHub
parent 1877543d03
commit c7d5d1d93b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -503,9 +503,14 @@ def register_readline():
if PYTHON_BASIC_REPL:
CAN_USE_PYREPL = False
else:
import _pyrepl.readline
import _pyrepl.unix_console
from _pyrepl.main import CAN_USE_PYREPL
original_path = sys.path
sys.path = [p for p in original_path if p != '']
try:
import _pyrepl.readline
import _pyrepl.unix_console
from _pyrepl.main import CAN_USE_PYREPL
finally:
sys.path = original_path
except ImportError:
return

View File

@ -0,0 +1 @@
Remove the current directory from ``sys.path`` when using PyREPL.