Message282215
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. |
|
Date |
User |
Action |
Args |
2016-12-02 02:30:44 | belopolsky | set | recipients:
+ belopolsky |
2016-12-02 02:30:44 | belopolsky | set | messageid: <1480645844.32.0.506545914898.issue28856@psf.upfronthosting.co.za> |
2016-12-02 02:30:44 | belopolsky | link | issue28856 messages |
2016-12-02 02:30:43 | belopolsky | create | |
|