[issue44439] PickleBuffer doesn't have __len__ method

Serhiy Storchaka report at bugs.python.org
Thu Jun 17 01:36:11 EDT 2021


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Oh, LZMAFile.write() should not use len() directly on input data because it does not always work correctly with memoryview and other objects supporting the buffer protocol. It should use memoryview(data).nbytes or data = memoryview(data).cast('B') if other byte-oriented operations (indexing, slicing) are used. See for example Lib/gzip.py, Lib/_pyio.py, Lib/_compression.py, Lib/ssl.py, Lib/socketserver.py, Lib/wave.py.

----------
nosy: +nadeem.vawda, serhiy.storchaka

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


More information about the Python-bugs-list mailing list