Skip to content

Commit 2661dc9

Browse files
authored
Merge pull request #22487 from anntzer/mtpc
Don't key MathTextParser cache off a mutable FontProperties.
2 parents 3c6efec + eaae8a0 commit 2661dc9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/matplotlib/mathtext.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,10 @@ def parse(self, s, dpi=72, prop=None):
233233
The results are cached, so multiple calls to `parse`
234234
with the same expression should be fast.
235235
"""
236-
# lru_cache can't decorate parse() directly because the ps.useafm and
237-
# mathtext.fontset rcParams also affect the parse (e.g. by affecting
238-
# the glyph metrics).
236+
# lru_cache can't decorate parse() directly because prop
237+
# is mutable; key the cache using an internal copy (see
238+
# text._get_text_metrics_with_cache for a similar case).
239+
prop = prop.copy() if prop is not None else None
239240
return self._parse_cached(s, dpi, prop)
240241

241242
@functools.lru_cache(50)

0 commit comments

Comments
 (0)