One function
_format_table in astanin/python-tabulate
The author described this change as “Fix support for separating lines”. It counts as a record because the check below fails on the code as it stood at 95ae5eb61 and passes on b1ed1fda6, with nothing else changed between the two runs.
Projectastanin/python-tabulate
Fix saved2023-07-20
Sharing licenceMIT · LICENSE
Change size+6 −7
What the code was meant to do, written into the code itself as a docstring
Produce a plain-text representation of the table.
The change
| 14 | 14 | append_row = _append_basic_row | |
| 15 | 15 | ||
| 16 | 16 | padded_headers = pad_row(headers, pad) | |
| 17 | - | padded_rows = [pad_row(row, pad) for row in rows] | |
| 18 | 17 | ||
| 19 | 18 | if fmt.lineabove and "lineabove" not in hidden: | |
| 20 | 19 | _append_line(lines, padded_widths, colaligns, fmt.lineabove) | |
| ⋯ | |||
| 24 | 23 | if fmt.linebelowheader and "linebelowheader" not in hidden: | |
| 25 | 24 | _append_line(lines, padded_widths, colaligns, fmt.linebelowheader) | |
| 26 | 25 | ||
| 27 | - | if padded_rows and fmt.linebetweenrows and "linebetweenrows" not in hidden: | |
| 26 | + | if rows and fmt.linebetweenrows and "linebetweenrows" not in hidden: | |
| 28 | 27 | # initial rows with a line below | |
| 29 | - | for row, ralign in zip(padded_rows[:-1], rowaligns): | |
| 28 | + | for row, ralign in zip(rows[:-1], rowaligns): | |
| 30 | 29 | append_row( | |
| 31 | - | lines, row, padded_widths, colaligns, fmt.datarow, rowalign=ralign | |
| 30 | + | lines, pad_row(row, pad), padded_widths, colaligns, fmt.datarow, rowalign=ralign | |
| 32 | 31 | ) | |
| 33 | 32 | _append_line(lines, padded_widths, colaligns, fmt.linebetweenrows) | |
| 34 | 33 | # the last row without a line below | |
| 35 | 34 | append_row( | |
| 36 | 35 | lines, | |
| 37 | - | padded_rows[-1], | |
| 36 | + | pad_row(rows[-1], pad), | |
| 38 | 37 | padded_widths, | |
| 39 | 38 | colaligns, | |
| 40 | 39 | fmt.datarow, | |
| ⋯ | |||
| 48 | 47 | or fmt.lineabove | |
| 49 | 48 | or Line("", "", "", "") | |
| 50 | 49 | ) | |
| 51 | - | for row in padded_rows: | |
| 50 | + | for row in rows: | |
| 52 | 51 | # test to see if either the 1st column or the 2nd column (account for showindex) has | |
| 53 | 52 | # the SEPARATING_LINE flag | |
| 54 | 53 | if _is_separating_line(row): | |
| 55 | 54 | _append_line(lines, padded_widths, colaligns, separating_line) | |
| 56 | 55 | else: | |
| 57 | - | append_row(lines, row, padded_widths, colaligns, fmt.datarow) | |
| 56 | + | append_row(lines, pad_row(row, pad), padded_widths, colaligns, fmt.datarow) | |
| 58 | 57 | ||
| 59 | 58 | if fmt.linebelow and "linebelow" not in hidden: | |
| 60 | 59 | _append_line(lines, padded_widths, colaligns, fmt.linebelow) | |
The check that tells the two apart
fail→pass·test/test_output.py::test_orgtbl_with_sep_line
Check file test/test_output.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it95ae5eb61ef969749e904c90ab429003238d6212
Broken version dated2023-04-30
Moduletabulate.__init__
Units changed_format_table
Fingerprint0cf7ed40f2dc791b
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in astanin/python-tabulate
- 2026-03-05_asciidoc_row
- 2026-03-05_format
- 2014-02-12_normalize_tabular_data
- 2013-11-20simple_separated_format
- 2013-08-09_normalize_tabular_data