Skip to content

Can't use .readinto on zlib.DecompIO: TypeError: object with buffer protocol required #9291

Discussion options

You must be logged in to vote

It seems that the usual fix for this problem is to "use strings/bytes instead of passed object"

Yes that is the correct way to do it, create a temporary bytearray to buffer the data from one stream to another.

but this doesn't make sense here as all of these objects should have the buffer protocol implemented

There is a difference between "buffer protocol" and "stream protocol". The former is an in-memory object like str, bytes, bytearray (mutable), memoryview and some other things. The latter is an object that has read/write methods (essentially inherits from IOBase).

I don't think CPython even allows reading directly from one file/stream into another?

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by knuxify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants