summaryrefslogtreecommitdiffstats
path: root/Modules/main.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-08-10 14:36:18 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-08-10 14:36:18 (GMT)
commitad73a9cf97770023665a1bb1c6390a3c99478139 (patch)
treeb04a3a8762fe6a99ae6c57743ebcfca6d71fe2bd /Modules/main.c
parent562d9cbfe9b11b5bd23810b4ee8a111a8c9aa5b8 (diff)
downloadcpython-ad73a9cf97770023665a1bb1c6390a3c99478139.zip
cpython-ad73a9cf97770023665a1bb1c6390a3c99478139.tar.gz
cpython-ad73a9cf97770023665a1bb1c6390a3c99478139.tar.bz2
Issue #16400: Add command line option for isolated mode.
-I Run Python in isolated mode. This also implies -E and -s. In isolated mode sys.path contains neither the script’s directory nor the user’s site-packages directory. All PYTHON* environment variables are ignored, too. Further restrictions may be imposed to prevent the user from injecting malicious code.
Diffstat (limited to 'Modules/main.c')
-rw-r--r--Modules/main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 435bd1b..25190b8 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -43,7 +43,7 @@ static wchar_t **orig_argv;
static int orig_argc;
/* command line options */
-#define BASE_OPTS L"bBc:dEhiJm:OqRsStuvVW:xX:?"
+#define BASE_OPTS L"bBc:dEhiIJm:OqRsStuvVW:xX:?"
#define PROGRAM_OPTS BASE_OPTS
@@ -65,6 +65,7 @@ Options and arguments (and corresponding environment variables):\n\
static char *usage_2 = "\
-i : inspect interactively after running script; forces a prompt even\n\
if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\
+-I : isolate Python from the user's environment (implies -E and -s)\n\
-m mod : run library module as a script (terminates option list)\n\
-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\
-OO : remove doc-strings in addition to the -O optimizations\n\
@@ -426,6 +427,12 @@ Py_Main(int argc, wchar_t **argv)
Py_InteractiveFlag++;
break;
+ case 'I':
+ Py_IsolatedFlag++;
+ Py_NoUserSiteDirectory++;
+ Py_IgnoreEnvironmentFlag++;
+ break;
+
/* case 'J': reserved for Jython */
case 'O':