Skip to content

fix: avoid IndexError when sizing a zero-column titled table - #483

Closed
santhreal wants to merge 2 commits into
prettytable:mainfrom
santhreal:fix/empty-table-title-width
Closed

fix: avoid IndexError when sizing a zero-column titled table#483
santhreal wants to merge 2 commits into
prettytable:mainfrom
santhreal:fix/empty-table-title-width

Conversation

@santhreal

@santhreal santhreal commented Jul 18, 2026

Copy link
Copy Markdown

PrettyTable._compute_widths hits IndexError when get_string(title=...) with zero columns. This PR fixes the regression with a focused test covering the case.

Empty PrettyTable instances with a title (or min_table_width) tried to
grow widths[-1] even when there were no columns. Skip width scaling when
the widths list is empty so get_string still returns a table.
@hugovk

hugovk commented Jul 28, 2026

Copy link
Copy Markdown
Member

You've opened many PRs across these repos two weeks ago, and then closed them with no comment:

python-humanize/humanize#352
python-humanize/humanize#353
#483
#484
jazzband/tablib#659
jazzband/tablib#660
jazzband/tablib#661

Please could you explain why?

Also hundreds in other repos:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants