[IronPython] Minor bug in conversion of str to bytes?
dinov at microsoft.com
Fri May 29 20:25:14 CEST 2009
Unfortunately there's probably going to continue to be a bunch of corner
cases related to bytes/str/unicode until we move to 3.0. But hopefully
we can come up w/ reasonable workarounds for most of them.
In this case it seems like we should define __str__ on bytes and make
it return a Unicode string w/o the b''. We can keep repr in there so
that an explicit repr still gives you the b'' representation...
Ahh, I can't wait until Ipy 3.0!
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Robert Smallshire
Sent: Friday, May 29, 2009 10:29 AM
To: 'Discussion of IronPython'
Subject: [IronPython] Minor bug in conversion of str to bytes?
Lets create a bytes instance from a str, and convert it back to a str.
>>> a = bytes(ord(c) for c in "Hello World")
As you can see, the leading b and the quotes become part of the string,
which is unexpected. I guess the conversion is using __repr__ where it
should use __str__.
Users mailing list
Users at lists.ironpython.com
More information about the Ironpython-users