summaryrefslogtreecommitdiff
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorKristján Valur Jónsson <sweskman@gmail.com>2013-03-19 15:07:35 -0700
committerKristján Valur Jónsson <sweskman@gmail.com>2013-03-19 15:07:35 -0700
commit8927e8f4211dc50b87a6365ed7281452a1931ebf (patch)
treec519bb98128d6fa159ea2ea9b2e1a8c9f2b69067 /Lib/subprocess.py
parentac0866f2ab9aa43c635618681682dd9f6da6219e (diff)
downloadcpython-git-8927e8f4211dc50b87a6365ed7281452a1931ebf.tar.gz
Issue #12098: multiprocessing on Windows now starts child processes
using the same sys.flags as the current process. Backport from default branch.
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 19a51889ea..309f9a3972 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -482,6 +482,37 @@ def _eintr_retry_call(func, *args):
raise
+# 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',
+ 'hash_randomization': 'R',
+ 'py3k_warning': '3',
+ }
+ 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, **kwargs):
"""Run command with arguments. Wait for command to complete, then
return the returncode attribute.