diff -r e948154af406 Lib/test/test_format.py --- a/Lib/test/test_format.py Sat Apr 13 18:00:04 2013 +0300 +++ b/Lib/test/test_format.py Sat Apr 13 16:56:50 2013 -0400 @@ -1,4 +1,5 @@ from test.support import verbose, TestFailed +import decimal import locale import sys import test.support as support @@ -307,6 +308,25 @@ finally: locale.setlocale(locale.LC_ALL, oldloc) + def test_null_padding_float(self): + # Issue 17705: Fill Character cannot be 0円 + self.assertEqual('{0:\x00>8.2f}'.format(12.0), '\x00\x00\x0012.00') + + def test_null_padding_long(self): + # Issue 17705: Fill Character cannot be 0円 + self.assertEqual('{0:\x00>8.2f}'.format(12), '\x00\x00\x0012.00') + + def test_null_padding_complex(self): + # Issue 17705: Fill Character cannot be 0円 + self.assertEqual('{0:\x00>8}'.format(complex(1, 2)), '\x00\x00(1+2j)') + + @unittest.skip('Decimal is not working yet') + def test_null_padding_decimal(self): + # Issue 17705: Fill Character cannot be 0円 + self.assertEqual( + '{0:\x00>8.2f}'.format(decimal.Decimal('12')), + '\x00\x00\x0012.00' + ) def test_main(): diff -r e948154af406 Python/formatter_unicode.c --- a/Python/formatter_unicode.c Sat Apr 13 18:00:04 2013 +0300 +++ b/Python/formatter_unicode.c Sat Apr 13 16:56:50 2013 -0400 @@ -157,7 +157,7 @@ Py_ssize_t consumed; int align_specified = 0; - format->fill_char = '0円'; + format->fill_char = ' '; format->align = default_align; format->alternate = 0; format->sign = '0円'; @@ -193,8 +193,8 @@ ++pos; } - /* The special case for 0-padding (backwards compat) */ - if (format->fill_char == '0円' && end-pos>= 1 && READ_spec(pos) == '0') { + /* The special case for 0-padding (backwards compat)*/ + if (format->fill_char == ' ' && end-pos>= 1 && READ_spec(pos) == '0') { format->fill_char = '0'; if (!align_specified) { format->align = '='; @@ -780,7 +780,7 @@ /* Write into that space. First the padding. */ result = fill_padding(writer, len, - format->fill_char=='0円'?' ':format->fill_char, + format->fill_char, lpad, rpad); if (result == -1) goto done; @@ -952,7 +952,7 @@ result = fill_number(writer, &spec, tmp, inumeric_chars, inumeric_chars + n_digits, tmp, prefix, - format->fill_char == '0円' ? ' ' : format->fill_char, + format->fill_char, &locale, format->type == 'X'); done: @@ -1095,7 +1095,7 @@ result = fill_number(writer, &spec, unicode_tmp, index, index + n_digits, NULL, 0, - format->fill_char == '0円' ? ' ' : format->fill_char, + format->fill_char, &locale, 0); done: @@ -1296,7 +1296,7 @@ /* Populate the memory. First, the padding. */ result = fill_padding(writer, n_re_total + n_im_total + 1 + add_parens * 2, - format->fill_char=='0円' ? ' ' : format->fill_char, + format->fill_char, lpad, rpad); if (result == -1) goto done;

AltStyle によって変換されたページ (->オリジナル) /