Bug description:
_pyio.BytesIO.peek() returns a bytearray, while io.BytesIO.peek() returns bytes, which is what Doc/library/io.rst documents. It also rejects an __index__-able size that the C version accepts.
importio, _pyioclassIdx:
def__index__(self):
return3formodin (io, _pyio):
b=mod.BytesIO(b'abcdef')
print(mod.__name__, 'peek() ->', type(b.peek()).__name__)
print(mod.__name__, 'peek(Idx()) ->', repr(b.peek(Idx())))
io peek() -> bytes
io peek(Idx()) -> b'abc'
_pyio peek() -> bytearray
_pyio peek(Idx()) -> TypeError: '<' not supported between instances of 'Idx' and 'int'
BytesIO.peek() is new in 3.16 (GH-150917).
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug description:
_pyio.BytesIO.peek()returns abytearray, whileio.BytesIO.peek()returnsbytes, which is whatDoc/library/io.rstdocuments. It also rejects an__index__-able size that the C version accepts.BytesIO.peek()is new in 3.16 (GH-150917).CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs