This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_format fails with -j combined with -v
Type: behavior Stage: patch review
Components: Tests Versions: Python 3.2
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, eric.smith, flox, jgsack, pitrou, r.david.murray, vstinner
Priority: low Keywords: patch

Created on 2009-12-18 03:42 by jgsack, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue7537_tolerant_stdout.diff flox, 2009-12-18 15:12 Patch, apply to py3k review
Messages (8)
msg96547 - (view) Author: James G. sack (jim) (jgsack) Date: 2009-12-18 03:42
With -r 76870, on Fedora 11, amd x80_64, regrtest of test_format fails 
when the -j  option is combined with the -v option. It happens whether 
testing everything or just the one test.

  ./python -Ebb Lib/test/regrtest -j3 -vv 
or
  ./python -Ebb Lib/test/regrtest -j3 -vv test_format

The error report is like
"""
FAILED (errors=1)
test test_format failed -- Traceback (most recent call last):
  File "/home/jbase/checkouts/py/py32/Lib/test/test_format.py", line 
221, in test_format
    testformat("%r", "\u0374", "'\u0374'")   # printable
  File "/home/jbase/checkouts/py/py32/Lib/test/test_format.py", line 20, 
in testformat
    (formatstr, args, output), end=' ')
UnicodeEncodeError: 'ascii' codec can't encode character '\u0374' in 
position 8: ordinal not in range(128)
1 test failed:
    test_format
"""

~jim
msg96550 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2009-12-18 07:52
I can duplicate this on Fedora Core 6, x86, r76872. I simplified the
command line down to:

./python Lib/test/regrtest.py -j1 -v test_format

(and any value for j >= 1 causes the error).
msg96558 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-12-18 11:09
This is because in -j mode stdout is a pipe, and so python defaults to
ascii for the output encoding.  I'm not sure what the best way is to fix
this.
msg96561 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-12-18 13:39
Maybe the "sys.stdout.write" method can be wrapped in a decorator or a
context manager?

See example of decorator attached.
msg112225 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-07-31 23:19
James, can you set PYTHONIOENCODING to a reasonable value in the test environment and see if it fixes the bug? (More info on http://docs.python.org/dev/using/cmdline#envvar-PYTHONIOENCODING)
msg112227 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-07-31 23:33
Funny, because it works here (Mandriva Linux, py3k branch).
Can you still reproduce?

(in any case, it doesn't make much sense to run in verbose mode with -jN, since it will interleave output from several tests)
msg118683 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-10-14 16:24
Unable to reproduce, here. It seems fixed.
msg125268 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-01-04 00:58
Seems to work, even when forcing LANG=C.
History
Date User Action Args
2022-04-11 14:56:55adminsetgithub: 51786
2011-01-04 00:58:59pitrousetstatus: pending -> closed
nosy: jgsack, pitrou, vstinner, eric.smith, eric.araujo, r.david.murray, flox
messages: + msg125268
2010-10-14 16:24:32floxsetstatus: open -> pending

nosy: + vstinner
messages: + msg118683

resolution: works for me
2010-07-31 23:33:02pitrousetmessages: + msg112227
2010-07-31 23:19:42eric.araujosetnosy: + eric.araujo
messages: + msg112225
2009-12-21 22:20:10floxsetstage: needs patch -> patch review
2009-12-18 15:12:35floxsetfiles: + issue7537_tolerant_stdout.diff
2009-12-18 15:11:56floxsetfiles: - issue7537_tolerant_stdout.diff
2009-12-18 13:39:24floxsetfiles: + issue7537_tolerant_stdout.diff

nosy: + flox
messages: + msg96561

keywords: + patch
2009-12-18 11:09:07r.david.murraysetpriority: low

nosy: + r.david.murray, pitrou
messages: + msg96558

type: behavior
stage: needs patch
2009-12-18 07:52:59eric.smithsetnosy: + eric.smith

messages: + msg96550
title: test_format -> test_format fails with -j combined with -v
2009-12-18 03:42:13jgsackcreate