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.

Author serhiy.storchaka
Recipients dabrahams, effbot, eli.bendersky, eric.araujo, flox, kune, serhiy.storchaka, vstinner
Date 2012-07-13.12:40:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1342183204.97.0.45497311864.issue9458@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-07-13 12:40:05serhiy.storchakasetrecipients: + serhiy.storchaka, effbot, vstinner, eric.araujo, kune, eli.bendersky, flox, dabrahams
2012-07-13 12:40:04serhiy.storchakasetmessageid: <1342183204.97.0.45497311864.issue9458@psf.upfronthosting.co.za>
2012-07-13 12:40:04serhiy.storchakalinkissue9458 messages
2012-07-13 12:40:03serhiy.storchakacreate