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 belopolsky
Recipients belopolsky
Date 2016-12-02.02:30:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1480645844.32.0.506545914898.issue28856@psf.upfronthosting.co.za>
In-reply-to
Content
Python 3.7.0a0 (default:be70d64bbf88, Dec  1 2016, 21:21:25)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from array import array
>>> a = array('B', [1, 2])
>>> b'%b' % a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: %b requires bytes, or an object that implements __bytes__, not 'array.array'
>>> m = memoryview(a)
>>> b'%b' % m
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: %b requires bytes, or an object that implements __bytes__, not 'memoryview'

Accorfing to documentation [1] objects that follow the buffer protocol should be supported.  Both array.array and memoryview follow the buffer protocol.

[1]: https://docs.python.org/3/library/stdtypes.html#printf-style-bytes-formatting


See also issue 20284 and PEP 461.
History
Date User Action Args
2016-12-02 02:30:44belopolskysetrecipients: + belopolsky
2016-12-02 02:30:44belopolskysetmessageid: <1480645844.32.0.506545914898.issue28856@psf.upfronthosting.co.za>
2016-12-02 02:30:44belopolskylinkissue28856 messages
2016-12-02 02:30:43belopolskycreate