Issue #29000: Fixed bytes formatting of octals with zero padding in alternate

form.
This commit is contained in:
Serhiy Storchaka 2016-12-17 21:48:03 +02:00
parent af56e0e70f
commit b1a1619bf0
3 changed files with 31 additions and 11 deletions

View file

@ -882,7 +882,7 @@ _PyBytes_Format(PyObject *format, PyObject *args)
if (width > len)
width--;
}
if ((flags & F_ALT) && (c == 'x' || c == 'X')) {
if ((flags & F_ALT) && (c == 'o' || c == 'x' || c == 'X')) {
assert(pbuf[0] == '0');
assert(pbuf[1] == c);
if (fill != ' ') {
@ -904,8 +904,7 @@ _PyBytes_Format(PyObject *format, PyObject *args)
if (fill == ' ') {
if (sign)
*res++ = sign;
if ((flags & F_ALT) &&
(c == 'x' || c == 'X')) {
if ((flags & F_ALT) && (c == 'o' || c == 'x' || c == 'X')) {
assert(pbuf[0] == '0');
assert(pbuf[1] == c);
*res++ = *pbuf++;