diff options
-rwxr-xr-x | Lib/test/regrtest.py | 9 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index 8d81bc9..5eea1d9 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -411,6 +411,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, support.verbose = verbose # Tell tests to be moderately quiet support.use_resources = use_resources save_modules = sys.modules.keys() + replace_stdout() for test in tests: if not quiet: print(test) @@ -556,6 +557,14 @@ def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS): tests.sort() return stdtests + tests +def replace_stdout(): + """Set stdout encoder error handler to backslashreplace (as stderr error + handler) to avoid UnicodeEncodeError when printing a traceback""" + stdout = sys.stdout + sys.stdout = open(stdout.fileno(), 'w', + encoding=stdout.encoding, + errors="backslashreplace") + def runtest(test, generate, verbose, quiet, test_times, testdir=None, huntrleaks=False, debug=False): """Run a single test. @@ -140,6 +140,9 @@ Build Tests ----- +- Issue #8533: regrtest uses backslashreplace error handler for stdout to avoid + UnicodeEncodeError (write non-ASCII character to stdout using ASCII encoding) + - Issue #8576: Remove use of find_unused_port() in test_smtplib and test_multiprocessing. Patch by Paul Moore. |