[Python-Dev] Should bytearray(b'a')[0] should 1-char or number?
Amaury Forgeot d'Arc
amauryfa at gmail.com
Fri May 2 13:48:48 CEST 2008
On Fri, May 2, 2008 at 11:47 AM, ocean wrote:
> # I tried to post this to bug tracker, but couldn't, so posted here...
>
> r62095 says
>
> >Fix and enable a skipped test:
> >with python 2.6, enumerating bytes yields 1-char strings, not numbers.
> >
> >Don't merge this into the py3k branch.
>
> This is true for bytes, but not for bytearray.
>
> >>> bytearray(b'a')[0]
> 97
> [28493 refs]
> >>> b'a'[0]
> 'a'
>
> And this causes error on my environment like this.
>
> ======================================================================
> FAIL: testDecoder (__main__.StatefulIncrementalDecoderTest)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "test_io.py", line 629, in testDecoder
> self.assertEquals(d.decode(input, eof), output)
> AssertionError: u'o.i.a.b.c.d.' != u'abcd.'
>
> But strange, I cannot see this error on python.org buildbot.
The buildbots don't fail, because StatefulIncrementalDecoderTest is
not listed in the run_unittest() call :-(.
I found the cause of the problem: in io.py, TextIOWrapper.tell() calls
decode() with a bytearray, without any reason it seems.
I will take care of this tonight, if bugs.python.org is available.
--
Amaury Forgeot d'Arc
More information about the Python-Dev
mailing list