Skip to content

FIX: validate empty cellText and cellColours in table() - #32616

Draft
klnmurthi12345 wants to merge 3 commits into
matplotlib:mainfrom
klnmurthi12345:fix-table-empty-celltext
Draft

klnmurthi12345 wants to merge 3 commits into
matplotlib:mainfrom
klnmurthi12345:fix-table-empty-celltext

Conversation

@klnmurthi12345

Copy link
Copy Markdown

PR summary

Closes #32614

When creating a table with ax.table(cellText=[]) or ax.table(cellText=[[]]) (or cellColours=[]), table() crashed with an unhandled IndexError: list index out of range or ZeroDivisionError: float division by zero because it indexed cellText[0] and divided by cols without checking row and column count.

This PR adds explicit checks in table():

  • Validates that cellText (or cellColours) has len > 0 (at least one row)
  • Validates that the first row has len > 0 (at least one column)
  • Raises descriptive ValueErrors:
    • ValueError("'cellText' must contain at least one row.")
    • ValueError("'cellText' must contain at least one column.")
  • Adds regression unit tests in lib/matplotlib/tests/test_table.py.

AI Disclosure

Assisted in drafting tests and verifying against test cases.

PR quality check

  • Use an expressive title, e.g. "Fix title font property precedence"
  • New and changed code is tested
  • [N/A] Plotting related features are demonstrated in an example
  • [N/A] New features and API changes have release notes
  • Documentation complies with general and docstring guidelines

@github-actions

Copy link
Copy Markdown

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

You can also join us on discourse chat for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@github-actions github-actions Bot added first-contribution AgentScan: mixed AgentScan detected an account with mixed automation signals. labels Nov 16, 2026
@timhoffm

Copy link
Copy Markdown
Member

Putting review on hold until we've clarified whether this is a real issue #32614 (comment).

@timhoffm
timhoffm marked this pull request as draft November 16, 2026 22:25
@rcomer

rcomer commented Nov 17, 2026

Copy link
Copy Markdown
Member

I note that AgentScan has now upgraded its evaluation of this account to “automated”.
https://agentscan.tools/user/klnmurthi12345

@rcomer rcomer added AgentScan: automated AgentScan classified an account as automated. and removed AgentScan: mixed AgentScan detected an account with mixed automation signals. labels Nov 17, 2026

This branch has not been deployed

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

Labels

AgentScan: automated AgentScan classified an account as automated. first-contribution topic: table

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: table() crashes with raw IndexError or ZeroDivisionError when passed empty cellText

3 participants