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

form.
This commit is contained in:
Serhiy Storchaka 2016-12-17 22:15:10 +02:00
commit 9d16b616d5
3 changed files with 31 additions and 11 deletions

View file

@ -974,7 +974,7 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
/* Write the numeric prefix for "x", "X" and "o" formats
if the alternate form is used.
For example, write "0x" for the "%#x" format. */
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 != ' ') {
@ -999,8 +999,7 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
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++;