mirror of https://github.com/python/cpython
bpo-30107: Make SuppressCrashReport quiet on macOS (#1279)
On macOS, SuppressCrashReport now redirects /usr/bin/defaults command stderr into a pipe to not pollute stderr. It fixes a test_io.test_daemon_threads_shutdown_stderr_deadlock() failure when the CrashReporter domain doesn't exists. Message logged into stderr: 2017-04-24 16:57:21.432 defaults[41046:2462851] The domain/default pair of (com.apple.CrashReporter, DialogType) does not exist
This commit is contained in:
parent
08c16016e2
commit
d819ad9832
|
@ -2447,6 +2447,7 @@ class SuppressCrashReport:
|
||||||
(0, self.old_value[1]))
|
(0, self.old_value[1]))
|
||||||
except (ValueError, OSError):
|
except (ValueError, OSError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
# Check if the 'Crash Reporter' on OSX was configured
|
# Check if the 'Crash Reporter' on OSX was configured
|
||||||
# in 'Developer' mode and warn that it will get triggered
|
# in 'Developer' mode and warn that it will get triggered
|
||||||
|
@ -2454,10 +2455,14 @@ class SuppressCrashReport:
|
||||||
#
|
#
|
||||||
# This assumes that this context manager is used in tests
|
# This assumes that this context manager is used in tests
|
||||||
# that might trigger the next manager.
|
# that might trigger the next manager.
|
||||||
value = subprocess.Popen(['/usr/bin/defaults', 'read',
|
cmd = ['/usr/bin/defaults', 'read',
|
||||||
'com.apple.CrashReporter', 'DialogType'],
|
'com.apple.CrashReporter', 'DialogType']
|
||||||
stdout=subprocess.PIPE).communicate()[0]
|
proc = subprocess.Popen(cmd,
|
||||||
if value.strip() == b'developer':
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
|
with proc:
|
||||||
|
stdout = proc.communicate()[0]
|
||||||
|
if stdout.strip() == b'developer':
|
||||||
print("this test triggers the Crash Reporter, "
|
print("this test triggers the Crash Reporter, "
|
||||||
"that is intentional", end='', flush=True)
|
"that is intentional", end='', flush=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue