Commit 59093b5
committed
gh-157466: Fix configparser writing a trailing space for empty values
RawConfigParser._write_section() always concatenates the padded
delimiter, so an option with an empty value is written as "key = ",
leaving a space at the end of the line.
Drop that space when the value is empty, but keep it when the
delimiter itself ends in whitespace (delimiters=(' ',)), where it is
the separator and is needed to read the option back. Values that
genuinely end in whitespace are untouched.
write() is the only caller of _write_section(), and all three call
sites pass the same delimiter, so the guard belongs there.1 parent fd0970c commit 59093b5
3 files changed
Lines changed: 33 additions & 0 deletions
File tree
- Lib
- test
- Misc/NEWS.d/next/Library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
997 | 997 | | |
998 | 998 | | |
999 | 999 | | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
1000 | 1007 | | |
1001 | 1008 | | |
1002 | 1009 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
752 | 752 | | |
753 | 753 | | |
754 | 754 | | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
755 | 776 | | |
756 | 777 | | |
757 | 778 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments