New submission from Alexander Belopolsky: 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. ---------- messages: 282215 nosy: belopolsky priority: normal severity: normal stage: test needed status: open title: %b format for bytes does not support objects that follow the buffer protocol type: behavior _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28856> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com