[issue46375] io.BytesIO does not have peek()

Marcel Martin report at bugs.python.org
Sat Jan 22 17:08:29 EST 2022


Marcel Martin <python at marcelm.net> added the comment:

I opened a PR, but I now wonder whether the missing peek() is by design.

First, I noticed that instead of using BytesIO directly, I can wrap the instance in an io.BufferedReader, which does have peek(). (It’s just a bit inconvenient.)

The second thing is that BytesIO is currently documented to inherit from BufferedIOBase, but if peek() is implemented, one could argue that BytesIO now should inherit from BufferedReader because it then has all the methods. And that seems to great a change from my perspective.

I’ll defer to someone more knowledgeable and do not mind at all if this issue is closed without action.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46375>
_______________________________________


More information about the Python-bugs-list mailing list