Message266537
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. |
|
Date |
User |
Action |
Args |
2016-05-28 06:44:41 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, pitrou, benjamin.peterson, r.david.murray, docs@python, python-dev, martin.panter, Henning.von.Bargen |
2016-05-28 06:44:41 | serhiy.storchaka | set | messageid: <1464417881.1.0.468302430782.issue20699@psf.upfronthosting.co.za> |
2016-05-28 06:44:41 | serhiy.storchaka | link | issue20699 messages |
2016-05-28 06:44:40 | serhiy.storchaka | create | |
|