diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-03 08:35:56 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-03 08:35:56 (GMT) |
commit | e7bb78139606d85bcf139dd108355de2d19d8756 (patch) | |
tree | e664cd4f9106d613daba69a9ddc64f50b80bb266 /Lib/test/regrtest.py | |
parent | 336e54f4c73299e0d716842f0accce2f5560304b (diff) | |
download | cpython-e7bb78139606d85bcf139dd108355de2d19d8756.zip cpython-e7bb78139606d85bcf139dd108355de2d19d8756.tar.gz cpython-e7bb78139606d85bcf139dd108355de2d19d8756.tar.bz2 |
Merged revisions 80694,80703 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r80694 | victor.stinner | 2010-05-02 11:37:08 +0200 (dim., 02 mai 2010) | 3 lines
Issue #8533: Write tracebacks and failed tests to sys.stderr instead of
sys.stdout to avoid UnicodeEncodeError (use backslashreplace error handler)
........
r80703 | victor.stinner | 2010-05-02 19:24:51 +0200 (dim., 02 mai 2010) | 4 lines
Issue #8533: revert r80694; try a different fix: regrtest uses backslashreplace
error handler for stdout to avoid UnicodeEncodeError (write non-ASCII character
to stdout using ASCII encoding)
........
Diffstat (limited to 'Lib/test/regrtest.py')
-rwxr-xr-x | Lib/test/regrtest.py | 9 |
1 files changed, 9 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. |