Skip to content

Fix invalid format string in set_xticklabels error message.#31758

Merged
timhoffm merged 1 commit into
matplotlib:mainfrom
anntzer:tl
May 27, 2026
Merged

Fix invalid format string in set_xticklabels error message.#31758
timhoffm merged 1 commit into
matplotlib:mainfrom
anntzer:tl

Conversation

@anntzer
Copy link
Copy Markdown
Contributor

@anntzer anntzer commented May 27, 2026

"=" happens to be a valid format string for numeric values, but not for arbitrary objects, so an error
(TypeError: unsupported format string passed to <objecttype>.__format__) would previously occur while formatting the error message for something like set_xticklabels(object()).

(The actual case where I saw this happen is when I wrongly passed a Formatter to set_xticklabels.)

Also remove a fairly pointless comment.

PR summary

AI Disclosure

PR checklist

"=" happens to be a valid format string for numeric values, but not for
arbitrary objects, so an error
(`TypeError: unsupported format string passed to <objecttype>.__format__`)
would previously occur *while formatting the error message* for
something like `set_xticklabels(object())`.

(The actual case where I saw this happen is when I wrongly passed a
Formatter to set_xticklabels.)

Also remove a fairly pointless comment.
@story645 story645 added this to the v3.11.0 milestone May 27, 2026
@timhoffm timhoffm merged commit 28cf237 into matplotlib:main May 27, 2026
43 checks passed
timhoffm added a commit that referenced this pull request May 27, 2026
timhoffm added a commit that referenced this pull request May 27, 2026
…758-on-v3.11.x

Backport PR #31758 on branch v3.11.x (Fix invalid format string in set_xticklabels error message.)
@anntzer anntzer deleted the tl branch May 28, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants