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! -----Original Message----- From: users-boun...@lists.ironpython.com [mailto:users-boun...@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? Hello, Lets create a bytes instance from a str, and convert it back to a str. >>> a = bytes(ord(c) for c in "Hello World") >>> a b'Hello World' >>> str(a) "b'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__. Cheers, Rob _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com