summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-01-18 11:15:08 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-01-18 11:15:08 (GMT)
commit9def2843873edde3feec6eaf2ee60c4e48172164 (patch)
tree9a7e862b8677c29fd877d55ea38b37d680087cfd /Lib/subprocess.py
parentc437d0cb4e99bd58ff0150414b5d5f0b26605687 (diff)
downloadcpython-9def2843873edde3feec6eaf2ee60c4e48172164.zip
cpython-9def2843873edde3feec6eaf2ee60c4e48172164.tar.gz
cpython-9def2843873edde3feec6eaf2ee60c4e48172164.tar.bz2
subprocess._optim_args_from_interpreter_flags()
Issue #26100: * Add subprocess._optim_args_from_interpreter_flags() * Add test.support.optim_args_from_interpreter_flags() * Use new functions in distutils, test_cmd_line_script, test_compileall and test_inspect The change enables test_details() test of test_inspect when -O or -OO command line option is used.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index d1324b8..640519d 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -520,6 +520,16 @@ DEVNULL = -3
# but it's here so that it can be imported when Python is compiled without
# threads.
+def _optim_args_from_interpreter_flags():
+ """Return a list of command-line arguments reproducing the current
+ optimization settings in sys.flags."""
+ args = []
+ value = sys.flags.optimize
+ if value > 0:
+ args.append('-' + 'O' * value)
+ return args
+
+
def _args_from_interpreter_flags():
"""Return a list of command-line arguments reproducing the current
settings in sys.flags and sys.warnoptions."""
@@ -527,7 +537,6 @@ def _args_from_interpreter_flags():
'debug': 'd',
# 'inspect': 'i',
# 'interactive': 'i',
- 'optimize': 'O',
'dont_write_bytecode': 'B',
'no_user_site': 's',
'no_site': 'S',
@@ -535,8 +544,9 @@ def _args_from_interpreter_flags():
'verbose': 'v',
'bytes_warning': 'b',
'quiet': 'q',
+ # -O is handled in _optim_args_from_interpreter_flags()
}
- args = []
+ args = _optim_args_from_interpreter_flags()
for flag, opt in flag_opt_map.items():
v = getattr(sys.flags, flag)
if v > 0: