Skip to content

Commit c9ca57e

Browse files
authored
bpo-30107: Make SuppressCrashReport quiet on macOS (#1279) (#1335)
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 (cherry picked from commit d819ad9)
1 parent 4dc3b9c commit c9ca57e

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
@@ -2433,17 +2433,22 @@ def __enter__(self):
24332433
(0, self.old_value[1]))
24342434
except (ValueError, OSError):
24352435
pass
2436+
24362437
if sys.platform == 'darwin':
24372438
# Check if the 'Crash Reporter' on OSX was configured
24382439
# in 'Developer' mode and warn that it will get triggered
24392440
# when it is.
24402441
#
24412442
# This assumes that this context manager is used in tests
24422443
# that might trigger the next manager.
2443-
value = subprocess.Popen(['/usr/bin/defaults', 'read',
2444-
'com.apple.CrashReporter', 'DialogType'],
2445-
stdout=subprocess.PIPE).communicate()[0]
2446-
if value.strip() == b'developer':
2444+
cmd = ['/usr/bin/defaults', 'read',
2445+
'com.apple.CrashReporter', 'DialogType']
2446+
proc = subprocess.Popen(cmd,
2447+
stdout=subprocess.PIPE,
2448+
stderr=subprocess.PIPE)
2449+
with proc:
2450+
stdout = proc.communicate()[0]
2451+
if stdout.strip() == b'developer':
24472452
print("this test triggers the Crash Reporter, "
24482453
"that is intentional", end='', flush=True)
24492454

0 commit comments

Comments
 (0)