Nikolaus Rath added the comment:

The attached patch now passes all testcases. 

However, every invocation of set_encoding() when there is buffered data leaks 
one reference. I haven't been able to find the error yet.

As for adding a reopen() or configure() method: I don't like it very much, but 
for the same reasons that I still don't like set_encoding() itself: it makes a 
rather fragile operation appear well-supported. set_encoding already inserts 
BOM in the middle of non-seekable streams, and invalidates tell cookies for 
seekable streams. Changing the buffering would probably face similar problems 
if there is buffered data but buffering is supposed to be turned off.


I think it would be better to restrict this functionality strictly to 
sys.stdin/out/err and in all other situations fix the API that results in the 
TextIO object with undesired parameters. For example, in the case of the 
subprocess module, wouldn't it be better to return pipes as byte streams and 
have the caller wrap them into text streams?

----------
Added file: http://bugs.python.org/file33874/set_encoding-5.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15216>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to