Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 5057:6c7a76fd5dc1 legacy-trunk
Fix bug reported by Per Lindqvist: "%#06x" % 1 stuck the 0 padding
in front of the 0x, like such: "0000x1".
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 29 Jan 1997 06:00:24 +0000 |
| parents | 62645787fbc8 |
| children | a44586bd9fab |
line wrap: on
line diff
--- a/Objects/stringobject.c Wed Jan 29 04:45:16 1997 +0000 +++ b/Objects/stringobject.c Wed Jan 29 06:00:24 1997 +0000 @@ -855,8 +855,20 @@ if (len < 0) goto error; sign = (c == 'd'); - if (flags&F_ZERO) + if (flags&F_ZERO) { fill = '0'; + if ((flags&F_ALT) && + (c == 'x' || c == 'X') && + buf[0] == '0' && buf[1] == c) { + *res++ = *buf++; + *res++ = *buf++; + rescnt -= 2; + len -= 2; + width -= 2; + if (width < 0) + width = 0; + } + } break; case 'e': case 'E':
