This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients Henning.von.Bargen, benjamin.peterson, docs@python, martin.panter, pitrou, python-dev, r.david.murray, serhiy.storchaka
Date 2016-05-28.06:44:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464417881.1.0.468302430782.issue20699@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-05-28 06:44:41serhiy.storchakasetrecipients: + serhiy.storchaka, pitrou, benjamin.peterson, r.david.murray, docs@python, python-dev, martin.panter, Henning.von.Bargen
2016-05-28 06:44:41serhiy.storchakasetmessageid: <1464417881.1.0.468302430782.issue20699@psf.upfronthosting.co.za>
2016-05-28 06:44:41serhiy.storchakalinkissue20699 messages
2016-05-28 06:44:40serhiy.storchakacreate