[issue28856] %b format for bytes does not support objects that follow the buffer protocol
Alexander Belopolsky
report at bugs.python.org
Thu Dec 1 21:30:44 EST 2016
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 <report at bugs.python.org>
<http://bugs.python.org/issue28856>
_______________________________________
More information about the Python-bugs-list
mailing list