Serhiy Storchaka added the comment:
Things are more complex in 2.7. Not all objects supporting old buffer protocol
support new buffer protocol, and not all functions accepting old buffer
protocol work with new buffer protocol.
>>> buffer(array.array('I'))
<read-only buffer for 0xb70fec00, size -1, offset 0 at 0xb70feb60>
>>> memoryview(array.array('I'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot make memory view because object does not have the buffer
interface
>>> zlib.compress(buffer('abc'))
"x\x9cKLJ\x06\x00\x02M\x01'"
>>> zlib.compress(memoryview('abc'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: compress() argument 1 must be string or read-only buffer, not
memoryview
The definition of the "bytes-like object" term (changed in 74e1c50498f8) looks
not correct in 2.7, because it mentions memoryview (rarely supported in 2.7
besides backported from 3.x features), but not buffer (widely supported in
2.7). It is referred only in one place (in Doc/library/hmac.rst, copied from
3.x in issue21306). I would suggest to avoid using this term, and be more
specific about supported protocols in every concrete case.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue20699>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com