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.

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

1414 append_row = _append_basic_row
1515
1616 padded_headers = pad_row(headers, pad)
17- padded_rows = [pad_row(row, pad) for row in rows]
1817
1918 if fmt.lineabove and "lineabove" not in hidden:
2019 _append_line(lines, padded_widths, colaligns, fmt.lineabove)
2423 if fmt.linebelowheader and "linebelowheader" not in hidden:
2524 _append_line(lines, padded_widths, colaligns, fmt.linebelowheader)
2625
27- if padded_rows and fmt.linebetweenrows and "linebetweenrows" not in hidden:
26+ if rows and fmt.linebetweenrows and "linebetweenrows" not in hidden:
2827 # 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):
3029 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
3231 )
3332 _append_line(lines, padded_widths, colaligns, fmt.linebetweenrows)
3433 # the last row without a line below
3534 append_row(
3635 lines,
37- padded_rows[-1],
36+ pad_row(rows[-1], pad),
3837 padded_widths,
3938 colaligns,
4039 fmt.datarow,
4847 or fmt.lineabove
4948 or Line("", "", "", "")
5049 )
51- for row in padded_rows:
50+ for row in rows:
5251 # test to see if either the 1st column or the 2nd column (account for showindex) has
5352 # the SEPARATING_LINE flag
5453 if _is_separating_line(row):
5554 _append_line(lines, padded_widths, colaligns, separating_line)
5655 else:
57- append_row(lines, row, padded_widths, colaligns, fmt.datarow)
56+ append_row(lines, pad_row(row, pad), padded_widths, colaligns, fmt.datarow)
5857
5958 if fmt.linebelow and "linebelow" not in hidden:
6059 _append_line(lines, padded_widths, colaligns, fmt.linebelow)

The check that tells the two apart

failpass·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