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 belopolsky, ethan.furman, serhiy.storchaka, skrah, xiang.zhang
Date 2017-03-07.11:16:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
printf-style bytes formatting was added mainly for increasing compatibility with Python 2. It was restricted to support mostly features existing in Python 2.

'%s' formatting in Python 3 supports bytes-like objects partially:

>>> b'%s' % array('B', [1, 2])
"array('B', [1, 2])"
>>> b'%s' % buffer(array('B', [1, 2]))
>>> b'%s' % memoryview(array('B', [1, 2]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot make memory view because object does not have the buffer interface
>>> b'%s' % bytearray(b'abc')
>>> b'%s' % buffer(bytearray(b'abc'))
>>> b'%s' % memoryview(bytearray(b'abc'))
'<memory at 0xb70902ac>'

I don't know whether there is a need of supporting the buffer protocol in printf-style bytes formatting. bytearray is already supported, buffer() doesn't exist in Python 3, memoryview() is not supported in Python 2. Seems this doesn't add anything for increasing the compatibility.
Date User Action Args
2017-03-07 11:16:23serhiy.storchakasetrecipients: + serhiy.storchaka, belopolsky, skrah, ethan.furman, xiang.zhang
2017-03-07 11:16:23serhiy.storchakasetmessageid: <>
2017-03-07 11:16:23serhiy.storchakalinkissue28856 messages
2017-03-07 11:16:23serhiy.storchakacreate