Skip to content

Recalculate headerless table width when extending rows - #497

Closed
vitalivo wants to merge 1 commit into
mahmoud:masterfrom
vitalivo:fix/headerless-table-extension
Closed

vitalivo wants to merge 1 commit into
mahmoud:masterfrom
vitalivo:fix/headerless-table-extension

Conversation

@vitalivo

Copy link
Copy Markdown

The change

Extending a headerless table with a wider row leaves its cached width unchanged. For example:

table = Table([[1]], headers=None)
table.extend([[2, 3]])

table.to_text() raises IndexError, and table.to_html(orientation='vertical') omits the second column. Recalculate the width when extending a headerless table so the existing filling step pads earlier rows. Tables with headers keep their current width behavior.

Two regression tests cover wider rows, shorter rows, iterator inputs, empty extensions, and the text and vertical HTML output. Both fail before the fix. On Linux with CPython 3.14.2, uv run --group dev pytest --doctest-modules boltons tests -q passes all 674 tests and doctests. git diff --check also passes.

The backstory

This is my first contribution to boltons. I wanted to support an open-source project with a concrete bug fix; this was found during a source review, rather than through a production incident. The useful finding here was that extending a table updates its rows but can leave the renderers using the old column count.

AI assistance

Tool: OpenAI Codex

Model: GPT-6

Original user request (relevant excerpt, translated from Russian): “You can look at projects across any tech stack. Look for vulnerabilities and bugs so we can support open source and help improve these projects.”

Codex investigated the bug, prepared the patch and regression tests, and ran the checks locally. Both new tests failed before the fix; all 674 tests passed afterward.

@vitalivo vitalivo closed this Sep 12, 2026
@vitalivo vitalivo reopened this Sep 12, 2026
mahmoud added a commit that referenced this pull request Oct 25, 2026
@mahmoud

mahmoud commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Folded into #609 (see the PR description for credit). Thanks for the report and the repro.

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