diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-11-20 23:24:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-20 23:24:56 (GMT) |
commit | f39b674876d2bd47ec7fc106d673b60ff24092ca (patch) | |
tree | 071bcd7373549e35207590f6b1593ae99022b6f0 /Lib/subprocess.py | |
parent | 423fd362f8e4d6c867a5afc8ac7cbeeb66cac19c (diff) | |
download | cpython-f39b674876d2bd47ec7fc106d673b60ff24092ca.zip cpython-f39b674876d2bd47ec7fc106d673b60ff24092ca.tar.gz cpython-f39b674876d2bd47ec7fc106d673b60ff24092ca.tar.bz2 |
bpo-32094: Update subprocess for -X dev (#4480)
Modify subprocess._args_from_interpreter_flags() to handle -X dev
option.
Add also unit tests for test.support.args_from_interpreter_flags()
and test.support.optim_args_from_interpreter_flags().
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r-- | Lib/subprocess.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 43be1f9..97b4493 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -260,8 +260,29 @@ def _args_from_interpreter_flags(): v = getattr(sys.flags, flag) if v > 0: args.append('-' + opt * v) - for opt in sys.warnoptions: + + # -W options + warnoptions = sys.warnoptions + xoptions = getattr(sys, '_xoptions', {}) + if 'dev' in xoptions and warnoptions and warnoptions[-1] == 'default': + # special case: -X dev adds 'default' to sys.warnoptions + warnoptions = warnoptions[:-1] + for opt in warnoptions: args.append('-W' + opt) + + # -X options + if 'dev' in xoptions: + args.extend(('-X', 'dev')) + for opt in ('faulthandler', 'tracemalloc', 'importtime', + 'showalloccount', 'showrefcount'): + if opt in xoptions: + value = xoptions[opt] + if value is True: + arg = opt + else: + arg = '%s=%s' % (opt, value) + args.extend(('-X', arg)) + return args |