summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-05-18 16:33:07 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-05-18 16:33:07 (GMT)
commitebdcd859e59ed16a79dea94291c0be3a87640a08 (patch)
tree4f91f5ec40375ba9bbdfacc2da79dd31bc440f89 /Lib/subprocess.py
parent77c84f2defb0013e28d262be237142379a1407fe (diff)
downloadcpython-ebdcd859e59ed16a79dea94291c0be3a87640a08.zip
cpython-ebdcd859e59ed16a79dea94291c0be3a87640a08.tar.gz
cpython-ebdcd859e59ed16a79dea94291c0be3a87640a08.tar.bz2
Move private function _args_from_interpreter_flags() to subprocess.py, so
that it can be imported when threads are disabled. (followup to issue #12098)
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 410ae29..1539891 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -475,6 +475,37 @@ def _eintr_retry_call(func, *args):
continue
+# XXX This function is only used by multiprocessing and the test suite,
+# but it's here so that it can be imported when Python is compiled without
+# threads.
+
+def _args_from_interpreter_flags():
+ """Return a list of command-line arguments reproducing the current
+ settings in sys.flags and sys.warnoptions."""
+ flag_opt_map = {
+ 'debug': 'd',
+ # 'inspect': 'i',
+ # 'interactive': 'i',
+ 'optimize': 'O',
+ 'dont_write_bytecode': 'B',
+ 'no_user_site': 's',
+ 'no_site': 'S',
+ 'ignore_environment': 'E',
+ 'verbose': 'v',
+ 'bytes_warning': 'b',
+ 'quiet': 'q',
+ 'hash_randomization': 'R',
+ }
+ args = []
+ for flag, opt in flag_opt_map.items():
+ v = getattr(sys.flags, flag)
+ if v > 0:
+ args.append('-' + opt * v)
+ for opt in sys.warnoptions:
+ args.append('-W' + opt)
+ return args
+
+
def call(*popenargs, timeout=None, **kwargs):
"""Run command with arguments. Wait for command to complete or
timeout, then return the returncode attribute.