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 r.david.murray
Recipients effbot, flox, r.david.murray, scoder
Date 2010-03-03.13:44:39
SpamBayes Score 3.27147e-06
Marked as misclassified No
Message-id <1267623881.94.0.139641830562.issue8047@psf.upfronthosting.co.za>
In-reply-to
Content
I'm not an ElementTree user, but that spelling (etree.tostring(encode=str), or even etree.tostring(encode=unicode)) strikes me as horrible.  You don't encode to unicode, you *decode* to unicode.  Thus the current Python3 interface works the way I'd expect: if I don't specify an encoding, I get unicode.  If I do specify an encoding, I get encoded bytes.  In the general case the fact that you can no longer get away with being sloppy about what encoding a byte stream is in, the way you could in Python2, is a feature of Python3, not a bug.

If anything, having 'tostring' return bytes is broken, given its name.  But I think we fudge that by claiming it is returning a 'byte string' when given an encoding.

That said, I'm not sure how much, if at all, my opinion counts :)
History
Date User Action Args
2010-03-03 13:44:42r.david.murraysetrecipients: + r.david.murray, effbot, scoder, flox
2010-03-03 13:44:41r.david.murraysetmessageid: <1267623881.94.0.139641830562.issue8047@psf.upfronthosting.co.za>
2010-03-03 13:44:40r.david.murraylinkissue8047 messages
2010-03-03 13:44:39r.david.murraycreate