From 4c63a972d194459ac17994d7f6d0be012880d740 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sat, 6 Oct 2012 23:55:33 +0200 Subject: 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. --- Objects/unicodeobject.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 0ed38fe..73a3dc4 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; -- cgit v0.12