Message165378
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. |
|
Date |
User |
Action |
Args |
2012-07-13 12:40:05 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, effbot, vstinner, eric.araujo, kune, eli.bendersky, flox, dabrahams |
2012-07-13 12:40:04 | serhiy.storchaka | set | messageid: <1342183204.97.0.45497311864.issue9458@psf.upfronthosting.co.za> |
2012-07-13 12:40:04 | serhiy.storchaka | link | issue9458 messages |
2012-07-13 12:40:03 | serhiy.storchaka | create | |
|