[New-bugs-announce] [issue8765] Tests unwillingly writing unicocde to raw streams

Pascal Chambon report at bugs.python.org
Wed May 19 14:17:55 CEST 2010

New submission from Pascal Chambon <chambon.pascal at gmail.com>:

In test_fileio, one of the tests wants to ensure writing to closed raw streams fails, but it actually tries to write an unicode string, which should rather lead to an immediate TypeError.

Here is a tiny patch to prevent the "double error cause" danger - this test is bugging me because my own I/O library cant pass the stdlib io tests in this case.

The initial problem here is that we can't write unicode to a buffered binary stream (TypeError), but we can do it with an unbufferred raw stream - as the C implementation of the latter does string coercion instead of raising TypeError.
Shouldn't we unify the behaviour of binary streams in such cases ?

components: IO
files: test_fileio_errclosedonwrite.patch
keywords: patch
messages: 106053
nosy: pakal
priority: normal
severity: normal
status: open
title: Tests unwillingly writing unicocde to raw streams
versions: Python 2.7
Added file: http://bugs.python.org/file17400/test_fileio_errclosedonwrite.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list