Skip to content

Commit c4f5aca

Browse files
committed
Fixed issue 5782: formatting with commas didn't work if no specifier type code was given.
1 parent 65475e7 commit c4f5aca

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

Lib/test/test_types.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ def test(i, format_spec, result):
405405
test(123456, "#012X", '0X000001E240')
406406
test(-123456, "#012X", '-0X00001E240')
407407

408+
# issue 5782, commas with no specifier type
409+
test(1234, '010,', '00,001,234')
410+
408411
# make sure these are errors
409412

410413
# precision disallowed
@@ -632,6 +635,9 @@ def test(f, format_spec, result):
632635
test(-1234.12341234, '013f', '-01234.123412')
633636
test(-123456.12341234, '011.2f', '-0123456.12')
634637

638+
# issue 5782, commas with no specifier type
639+
test(1.2, '010,.2', '0,000,001.2')
640+
635641
# 0 padding with commas
636642
test(1234., '011,f', '1,234.000000')
637643
test(1234., '012,f', '1,234.000000')

Objects/stringlib/formatter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ parse_internal_render_format_spec(STRINGLIB_CHAR *format_spec,
248248
case 'G':
249249
case '%':
250250
case 'F':
251+
case '\0':
251252
/* These are allowed. See PEP 378.*/
252253
break;
253254
default:

0 commit comments

Comments
 (0)