Issue1959
Created on 2012-08-15.11:25:33 by pjac, last changed 2012-08-18.06:20:44 by jeff.allen.
msg7409 (view) |
Author: Peter (pjac) |
Date: 2012-08-15.11:25:32 |
|
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
|
msg7412 (view) |
Author: Jeff Allen (jeff.allen) |
Date: 2012-08-18.06:20:43 |
|
Duplicates fixed Issue #1927.
>dist\bin\jython
Jython 2.7.0a2+ (, Aug 1 2012, 09:01:31)
[Java HotSpot(TM) 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0_26
Type "help", "copyright", "credits" or "license" for more information.
>>> from io import BytesIO
>>> raw = "\x01\x02\x03\x04"
>>> raw == BytesIO(raw).read()
True
>>> raw
'\x01\x02\x03\x04'
>>> type(raw)
<type 'str'>
>>> quit()
It stemmed from confusion (mine) over str() and repr() in bytearray. Thanks for testing!
|
|
Date |
User |
Action |
Args |
2012-08-18 06:20:44 | jeff.allen | set | status: open -> closed superseder: BytesIO.getvalue() includes string "bytearray()" messages:
+ msg7412 assignee: jeff.allen nosy:
+ jeff.allen, fwierzbicki resolution: duplicate |
2012-08-15 15:51:53 | tiagoantao | set | nosy:
+ tiagoantao |
2012-08-15 11:25:33 | pjac | create | |
|