diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-04-28 01:27:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-28 01:27:51 (GMT) |
commit | c9ca57eeea4d9da748d84281506c5803512b79ac (patch) | |
tree | d6b38e4f2f235e57d6ffa8420cbf2fbd3579af71 | |
parent | 4dc3b9cf2a868a8378ecbc2221a15e7b59e8e944 (diff) | |
download | cpython-c9ca57eeea4d9da748d84281506c5803512b79ac.zip cpython-c9ca57eeea4d9da748d84281506c5803512b79ac.tar.gz cpython-c9ca57eeea4d9da748d84281506c5803512b79ac.tar.bz2 |
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 d819ad9832292d854e9710493ecdf959b69802e3)
-rw-r--r-- | Lib/test/support/__init__.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 15d8fc8..1621e3d 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -2433,6 +2433,7 @@ class SuppressCrashReport: (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 @@ -2440,10 +2441,14 @@ class SuppressCrashReport: # # 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) |