Skip to content

Don't key MathTextParser cache off a mutable FontProperties. #22487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/matplotlib/mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ def parse(self, s, dpi=72, prop=None):
The results are cached, so multiple calls to `parse`
with the same expression should be fast.
"""
# lru_cache can't decorate parse() directly because the ps.useafm and
# mathtext.fontset rcParams also affect the parse (e.g. by affecting
# the glyph metrics).
# lru_cache can't decorate parse() directly because prop
# is mutable; key the cache using an internal copy (see
# text._get_text_metrics_with_cache for a similar case).
prop = prop.copy() if prop is not None else None
return self._parse_cached(s, dpi, prop)

@functools.lru_cache(50)
Expand Down