One function
_normalize_tabular_data in astanin/python-tabulate
The author described this change as “fix #9: tabulate iterator of iterators with headers”. It counts as a record because the check below fails on the code as it stood at 0ab146122 and passes on e20994384, with nothing else changed between the two runs.
Projectastanin/python-tabulate
Fix saved2013-08-09
Sharing licenceMIT · LICENSE
Change size+7 −3
What the code was meant to do, written into the code itself as a docstring
Transform a supported data type to a list of lists, and a list of headers. Supported tabular data types: * list-of-lists or another iterable of iterables * 2D NumPy arrays * dict of iterables (usually used with headers="keys") * pandas.DataFrame (usually used with headers="keys") The first row can be used as headers if headers="firstrow", column indices can be used as headers if headers="keys".
The change
| 43 | 43 | # take headers from the first row if necessary | |
| 44 | 44 | if headers == "firstrow" and len(rows) > 0: | |
| 45 | 45 | headers = list(map(_text_type, rows[0])) # headers should be strings | |
| 46 | - | rows = list(rows[1:]) | |
| 46 | + | rows = rows[1:] | |
| 47 | 47 | ||
| 48 | + | headers = list(headers) | |
| 49 | + | rows = list(map(list,rows)) | |
| 50 | + | ||
| 48 | 51 | # pad with empty headers for initial columns if necessary | |
| 49 | 52 | if headers and len(rows) > 0: | |
| 50 | 53 | nhs = len(headers) | |
| 51 | 54 | ncols = len(rows[0]) | |
| 52 | - | headers = [u""]*(ncols - nhs) + list(headers) | |
| 55 | + | if nhs < ncols: | |
| 56 | + | headers = [u""]*(ncols - nhs) + headers | |
| 53 | 57 | ||
| 54 | - | return list(map(list,rows)), list(headers) | |
| 58 | + | return rows, headers |
The check that tells the two apart
fail→pass·test_input.py::test_iterable_of_iterables_headers
Check file test_input.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 it0ab146122d2d3da81675234f6021fa8c012d074d
Broken version dated2013-08-09
Moduletabulate
Units changed_normalize_tabular_data
Fingerprint1b9e406777f2676d
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
- 2023-07-20_format_table
- 2014-02-12_normalize_tabular_data
- 2013-11-20simple_separated_format