Message7409

Author pjac
Recipients pjac
Date 2012-08-15.11:25:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1345029933.42.0.74754319856.issue1959@psf.upfronthosting.co.za>
In-reply-to
Content
Desired behaviour,

$ python2.7
Python 2.7.2 (default, Jun 20 2012, 16:23:33) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> raw = "\x01\x02\x03\x04"
>>> from io import BytesIO
>>> raw == BytesIO(raw).read()
True
>>> raw
'\x01\x02\x03\x04'
>>> type(raw)
<type 'str'>
>>> quit()

Broken behaviour under Jython 2.7a2 (on Mac OS X),

$ ~/jython2.7a2/jython
Jython 2.7a2 (default:9c148a201233, May 24 2012, 15:49:00) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_33
Type "help", "copyright", "credits" or "license" for more information.
>>> raw = "\x01\x02\x03\x04"
>>> from io import BytesIO
>>> raw == BytesIO(raw).read()
False
>>> raw
'\x01\x02\x03\x04'
>>> BytesIO(raw).read()
"bytearray(b'\\x01\\x02\\x03\\x04')"
>>> type(raw)
<type 'str'>
>>> type(BytesIO(raw).read())
<type 'str'>
>>> quit()

Notice that calling the read method of the BytesIO object is returning a string starting bytearray!

This bug was found by debugging failing Biopython unit tests:
http://lists.open-bio.org/pipermail/biopython-dev/2012-August/009870.html
History
Date User Action Args
2012-08-15 11:25:33pjacsetrecipients: + pjac
2012-08-15 11:25:33pjacsetmessageid: <1345029933.42.0.74754319856.issue1959@psf.upfronthosting.co.za>
2012-08-15 11:25:33pjaclinkissue1959 messages
2012-08-15 11:25:32pjaccreate