|
From: Peter <re...@bu...> - 2012-08-15 11:25:40
|
New submission from Peter: 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 ---------- messages: 7409 nosy: pjac severity: normal status: open title: io.BytesIO read method returns string "bytearray(b'...')" versions: 2.7a2 _______________________________________ Jython tracker <re...@bu...> <http://bugs.jython.org/issue1959> _______________________________________ |