From: Victor Stinner Date: Sun, 2 May 2010 09:37:08 +0000 (+0000) Subject: Issue #8533: Write tracebacks and failed tests to sys.stderr instead of X-Git-Tag: v3.2a1~954 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d80a5874ae2177b4352f997f962062d81734d4c;p=python Issue #8533: Write tracebacks and failed tests to sys.stderr instead of sys.stdout to avoid UnicodeEncodeError (use backslashreplace error handler) --- diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index c432ca48e8..ec49b9564c 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -939,8 +939,8 @@ def runtest_inner(test, verbose, quiet, print("test", test, "crashed --", str(type) + ":", value) sys.stdout.flush() if verbose or debug: - traceback.print_exc(file=sys.stdout) - sys.stdout.flush() + traceback.print_exc(file=sys.stderr) + sys.stderr.flush() return FAILED, test_time else: if refleak: diff --git a/Lib/test/support.py b/Lib/test/support.py index 4ea6c055a7..3c4d5d6bcf 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -1020,7 +1020,7 @@ def check_impl_detail(**guards): def _run_suite(suite): """Run tests from a unittest.TestSuite-derived class.""" if verbose: - runner = unittest.TextTestRunner(sys.stdout, verbosity=2) + runner = unittest.TextTestRunner(sys.stderr, verbosity=2) else: runner = BasicTestRunner() diff --git a/Misc/NEWS b/Misc/NEWS index 17702c7b51..f935480417 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1198,6 +1198,9 @@ Documentation Tests ----- +- Issue #8533: Write tracebacks and failed tests to sys.stderr instead of + sys.stdout to avoid UnicodeEncodeError (use backslashreplace error handler) + - Issue #8576: Remove use of find_unused_port() in test_smtplib and test_multiprocessing. Patch by Paul Moore.