From: Victor Stinner Date: Sat, 6 Oct 2012 21:55:33 +0000 (+0200) Subject: Cleanup PyUnicode_FromFormatV() for zero padding X-Git-Tag: v3.4.0a1~2327 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c63a972d194459ac17994d7f6d0be012880d740;p=python Cleanup PyUnicode_FromFormatV() for zero padding Skip the "0" instead of parsing it twice: detect zero padding and then parsed as a digit of the width. --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 0ed38fef8f..73a3dc48d2 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2349,7 +2349,11 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer, p = f; f++; - zeropad = (*f == '0'); + zeropad = 0; + if (*f == '0') { + zeropad = 1; + f++; + } /* parse the width.precision part, e.g. "%2.5s" => width=2, precision=5 */ width = 0;