summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 35bfddd..301433c 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -241,7 +241,7 @@ def _optim_args_from_interpreter_flags():
def _args_from_interpreter_flags():
"""Return a list of command-line arguments reproducing the current
- settings in sys.flags and sys.warnoptions."""
+ settings in sys.flags, sys.warnoptions and sys._xoptions."""
flag_opt_map = {
'debug': 'd',
# 'inspect': 'i',
@@ -262,12 +262,22 @@ def _args_from_interpreter_flags():
args.append('-' + opt * v)
# -W options
- for opt in sys.warnoptions:
+ warnopts = sys.warnoptions[:]
+ bytes_warning = sys.flags.bytes_warning
+ xoptions = getattr(sys, '_xoptions', {})
+ dev_mode = ('dev' in xoptions)
+
+ if bytes_warning > 1:
+ warnopts.remove("error::BytesWarning")
+ elif bytes_warning:
+ warnopts.remove("default::BytesWarning")
+ if dev_mode:
+ warnopts.remove('default')
+ for opt in warnopts:
args.append('-W' + opt)
# -X options
- xoptions = getattr(sys, '_xoptions', {})
- if 'dev' in xoptions:
+ if dev_mode:
args.extend(('-X', 'dev'))
for opt in ('faulthandler', 'tracemalloc', 'importtime',
'showalloccount', 'showrefcount'):