]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-30107: don't dump core on expected test_io crash (#1235) (#1241)
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 21 Apr 2017 16:27:29 +0000 (18:27 +0200)
committerGitHub <noreply@github.com>
Fri, 21 Apr 2017 16:27:29 +0000 (18:27 +0200)
test_io has two unit tests which trigger a deadlock:

* test_daemon_threads_shutdown_stdout_deadlock()
* test_daemon_threads_shutdown_stderr_deadlock()

These tests call Py_FatalError() if the expected bug is triggered
which calls abort(). Use test.support.SuppressCrashReport to prevent
the creation on a core dump, to fix the warning:

Warning -- files was modified by test_io
  Before: []
  After:  ['python.core']
(cherry picked from commit 2a1aed04b0943636f605543522e16cca1dc23e70)

Lib/test/test_io.py

index 5a7617cd9f9cbf342673b504abb08d95352191e5..8c91ad2ad8aa1c09f0ead1917df56bd614cd6115 100644 (file)
@@ -3720,6 +3720,7 @@ class CMiscIOTest(MiscIOTest):
             import sys
             import time
             import threading
+            from test.support import SuppressCrashReport
 
             file = sys.{stream_name}
 
@@ -3728,6 +3729,10 @@ class CMiscIOTest(MiscIOTest):
                     file.write('.')
                     file.flush()
 
+            crash = SuppressCrashReport()
+            crash.__enter__()
+            # don't call __exit__(): the crash occurs at Python shutdown
+
             thread = threading.Thread(target=run)
             thread.daemon = True
             thread.start()