1. Armin Rigo
  2. cpython-withatomic

Commits

Alexandre Vassalotti  committed 7486c29

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.

  • Participants
  • Parent commits 74b9c85
  • Branches default

Comments (0)

Files changed (2)

File Lib/io.py

View file
         if n < 0:
             n = len(self._buffer)
         if len(self._buffer) <= self._pos:
-            return self._buffer[:0]
+            return bytes(self._buffer[:0])
         newpos = min(len(self._buffer), self._pos + n)
         b = self._buffer[self._pos : newpos]
         self._pos = newpos

File Lib/test/test_memoryio.py

View file
         self.assertEqual(memio.read(-1), buf)
         memio.seek(0)
         self.assertEqual(type(memio.read()), type(buf))
+        memio.seek(100)
+        self.assertEqual(type(memio.read()), type(buf))
         memio.seek(0)
         self.assertEqual(memio.read(None), buf)
         self.assertRaises(TypeError, memio.read, '')