mirror of
https://github.com/python/cpython.git
synced 2025-09-18 14:40:43 +00:00
Fix bug reported by Per Lindqvist: "%#06x" % 1 stuck the 0 padding
in front of the 0x, like such: "0000x1".
This commit is contained in:
parent
9e5656ca3f
commit
4acdc2327f
1 changed files with 13 additions and 1 deletions
|
@ -855,8 +855,20 @@ formatstring(format, args)
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
goto error;
|
goto error;
|
||||||
sign = (c == 'd');
|
sign = (c == 'd');
|
||||||
if (flags&F_ZERO)
|
if (flags&F_ZERO) {
|
||||||
fill = '0';
|
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;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
case 'E':
|
case 'E':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue