[Python-3000-checkins] r62802 - in python/branches/py3k/Lib: io.py test/test_memoryio.py

Guido van Rossum guido at python.org
Wed May 7 01:56:28 CEST 2008


On Tue, May 6, 2008 at 4:47 PM, alexandre.vassalotti
<python-3000-checkins at python.org> wrote:
> Author: alexandre.vassalotti
>  Date: Wed May  7 01:47:23 2008
>  New Revision: 62802
>
>  Log:
>  Fixed a small bug introduced by r62778.
>
>  One of the codepaths of _BytesIO.read() returned a bytearray
>  object, by mistake, when it should always return a bytes object.
>  Interestingly, the fact this bug shown up probably means that
>  some platforms are not using the new C-accelerated io.BytesIO.
>
>
>  Modified:
>    python/branches/py3k/Lib/io.py
>    python/branches/py3k/Lib/test/test_memoryio.py
>
>  Modified: python/branches/py3k/Lib/io.py
>  ==============================================================================
>  --- python/branches/py3k/Lib/io.py      (original)
>  +++ python/branches/py3k/Lib/io.py      Wed May  7 01:47:23 2008
>  @@ -794,7 +794,7 @@
>          if n < 0:
>              n = len(self._buffer)
>          if len(self._buffer) <= self._pos:
>  -            return self._buffer[:0]
>  +            return bytes(self._buffer[:0])

This is an odd way of returning an empty bytes object -
self._buffer[:0] is an empty bytesarray.

>          newpos = min(len(self._buffer), self._pos + n)
>          b = self._buffer[self._pos : newpos]
>          self._pos = newpos
>

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000-checkins mailing list