summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-17 20:13:05 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-17 20:13:05 (GMT)
commit025f8953f1eff11d1eb3cb5d2068a31e6f6c7270 (patch)
treee7ff669617e6385c645289853443170d1eb770dc /Objects
parent75862c4c66cb23edbaf1b370cb7a355108edfd49 (diff)
parentb1a1619bf042cd9d51d83c5120cec51a6f27e906 (diff)
downloadcpython-025f8953f1eff11d1eb3cb5d2068a31e6f6c7270.zip
cpython-025f8953f1eff11d1eb3cb5d2068a31e6f6c7270.tar.gz
cpython-025f8953f1eff11d1eb3cb5d2068a31e6f6c7270.tar.bz2
Issue #29000: Fixed bytes formatting of octals with zero padding in alternate
form.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytesobject.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 779fe29..b22e57e 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -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++;