Skip to content

Commit d819ad9

Browse files
authored
bpo-30107: Make SuppressCrashReport quiet on macOS (python#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
1 parent 08c1601 commit d819ad9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Lib/test/support/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,17 +2447,22 @@ def __enter__(self):
24472447
(0, self.old_value[1]))
24482448
except (ValueError, OSError):
24492449
pass
2450+
24502451
if sys.platform == 'darwin':
24512452
# Check if the 'Crash Reporter' on OSX was configured
24522453
# in 'Developer' mode and warn that it will get triggered
24532454
# when it is.
24542455
#
24552456
# This assumes that this context manager is used in tests
24562457
# that might trigger the next manager.
2457-
value = subprocess.Popen(['/usr/bin/defaults', 'read',
2458-
'com.apple.CrashReporter', 'DialogType'],
2459-
stdout=subprocess.PIPE).communicate()[0]
2460-
if value.strip() == b'developer':
2458+
cmd = ['/usr/bin/defaults', 'read',
2459+
'com.apple.CrashReporter', 'DialogType']
2460+
proc = subprocess.Popen(cmd,
2461+
stdout=subprocess.PIPE,
2462+
stderr=subprocess.PIPE)
2463+
with proc:
2464+
stdout = proc.communicate()[0]
2465+
if stdout.strip() == b'developer':
24612466
print("this test triggers the Crash Reporter, "
24622467
"that is intentional", end='', flush=True)
24632468

0 commit comments

Comments
 (0)