[Python-checkins] r80711 - in python/branches/release31-maint: Lib/test/regrtest.py Misc/NEWS

victor.stinner python-checkins at python.org
Mon May 3 10:35:56 CEST 2010


Author: victor.stinner
Date: Mon May  3 10:35:56 2010
New Revision: 80711

Log:
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)
........


Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Lib/test/regrtest.py
   python/branches/release31-maint/Misc/NEWS

Modified: python/branches/release31-maint/Lib/test/regrtest.py
==============================================================================
--- python/branches/release31-maint/Lib/test/regrtest.py	(original)
+++ python/branches/release31-maint/Lib/test/regrtest.py	Mon May  3 10:35:56 2010
@@ -411,6 +411,7 @@
     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 @@
     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.

Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Mon May  3 10:35:56 2010
@@ -140,6 +140,9 @@
 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.
 


More information about the Python-checkins mailing list