Issue #28192: Don't import readline in isolated mode
diff --git a/Lib/site.py b/Lib/site.py
index 5250266..b637635 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -60,7 +60,8 @@
The readline module is also automatically configured to enable
completion for systems that support it. This can be overridden in
-sitecustomize, usercustomize or PYTHONSTARTUP.
+sitecustomize, usercustomize or PYTHONSTARTUP. Starting Python in
+isolated mode (-I) disables automatic readline configuration.
After these operations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
@@ -491,7 +492,7 @@
else:
raise
except Exception as err:
- if os.environ.get("PYTHONVERBOSE"):
+ if sys.flags.verbose:
sys.excepthook(*sys.exc_info())
else:
sys.stderr.write(
@@ -511,7 +512,7 @@
else:
raise
except Exception as err:
- if os.environ.get("PYTHONVERBOSE"):
+ if sys.flags.verbose:
sys.excepthook(*sys.exc_info())
else:
sys.stderr.write(
@@ -538,12 +539,13 @@
setquit()
setcopyright()
sethelper()
- enablerlcompleter()
+ if not sys.flags.isolated:
+ enablerlcompleter()
execsitecustomize()
if ENABLE_USER_SITE:
execusercustomize()
-# Prevent edition of sys.path when python was started with -S and
+# Prevent extending of sys.path when python was started with -S and
# site is imported later.
if not sys.flags.no_site:
main()