Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r87092:29d2a8abaa5f
Date: 2016-09-13 19:46 +0200
http://bitbucket.org/pypy/pypy/changeset/29d2a8abaa5f/

Log:    Implement the -I option to pypy

diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -12,6 +12,7 @@
 -h     : print this help message and exit (also --help)
 -i     : inspect interactively after running script; forces a prompt even
          if stdin does not appear to be a terminal; also PYTHONINSPECT=x
+-I     : isolate Python from the user's environment (implies -E and -s)
 -m mod : run library module as a script (terminates option list)
 -O     : skip assert statements; also PYTHONOPTIMIZE=x
 -OO    : remove docstrings when importing modules in addition to -O
@@ -349,6 +350,7 @@
     "bytes_warning",
     "quiet",
     "hash_randomization",
+    "isolated",
 )
 
 default_options = dict.fromkeys(
@@ -362,6 +364,11 @@
 def simple_option(options, name, iterargv):
     options[name] += 1
 
+def isolated_option(options, name, iterargv):
+    options[name] += 1
+    options["no_user_site"] += 1
+    options["ignore_environment"] += 1
+
 def c_option(options, runcmd, iterargv):
     options["run_command"] = runcmd
     return ['-c'] + list(iterargv)
@@ -388,6 +395,7 @@
     'B': (simple_option, 'dont_write_bytecode'),
     'd': (simple_option, 'debug'),
     'E': (simple_option, 'ignore_environment'),
+    'I': (isolated_option, 'isolated'),
     'i': (simple_option, 'interactive'),
     'O': (simple_option, 'optimize'),
     's': (simple_option, 'no_user_site'),
diff --git a/pypy/interpreter/test/test_app_main.py 
b/pypy/interpreter/test/test_app_main.py
--- a/pypy/interpreter/test/test_app_main.py
+++ b/pypy/interpreter/test/test_app_main.py
@@ -193,6 +193,7 @@
             ("ignore_environment", "-E", "1"),
             ("verbose", "-v", "1"),
             ("bytes_warning", "-b", "1"),
+            (["isolated", "no_user_site", "ignore_environment"], "-I", "1"),
         )
         for flag, opt, value in flags:
             if isinstance(flag, list):   # this is for inspect&interactive
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to