Serhiy Storchaka <storch...@gmail.com> added the comment:

ElementTree write works with two kinds of output -- binary and text. The 
difference between them is only determined by encoding argument. If encoding is 
"unicode", then output is text, else it is binary. There is no other way for 
filename or general file-like object to determine kind of output. If these are 
not explained in the documentation, then the documentation should be improved.

The patch can cause data corruption because direct writing to underlying file 
by fileno conflicts with TextIOBase/BufferedIOBase internal buffering. And not 
every file-like object have fileno. With patch the behavior becomes less 
obvious and will lead to confusion.

I don't see a behavior bug which should be fixed.

Only one thing can be enhanced -- error diagnostic in some corner cases. When 
we can determines that file object is instance of RawIOBase or TextIOBase and 
it is conflicts with encoding argument value, it will be helpful for novices to 
raise a descriptive exception. This is of course not eliminate all causes for 
confusing.

----------
nosy: +storchaka

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

Reply via email to