Skip to content

Commit

Permalink
bpo-30107: Make SuppressCrashReport quiet on macOS (#1279) (#1335)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
vstinner committed Apr 28, 2017
1 parent 4dc3b9c commit c9ca57e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2433,17 +2433,22 @@ def __enter__(self):
(0, self.old_value[1]))
except (ValueError, OSError):
pass

if sys.platform == 'darwin':
# Check if the 'Crash Reporter' on OSX was configured
# in 'Developer' mode and warn that it will get triggered
# when it is.
#
# This assumes that this context manager is used in tests
# that might trigger the next manager.
value = subprocess.Popen(['/usr/bin/defaults', 'read',
'com.apple.CrashReporter', 'DialogType'],
stdout=subprocess.PIPE).communicate()[0]
if value.strip() == b'developer':
cmd = ['/usr/bin/defaults', 'read',
'com.apple.CrashReporter', 'DialogType']
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
with proc:
stdout = proc.communicate()[0]
if stdout.strip() == b'developer':
print("this test triggers the Crash Reporter, "
"that is intentional", end='', flush=True)

Expand Down

0 comments on commit c9ca57e

Please sign in to comment.