Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit99aeb16

Browse files
tacaswellQuLogic
authored andcommitted
FIX: do not raise in lru_cached function
If the cached function raises it will not be cached and we will continuouslypay for cache misses.
1 parenta1cd412 commit99aeb16

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎lib/matplotlib/font_manager.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,9 +1345,12 @@ def findfont(self, prop, fontext='ttf', directory=None,
13451345
rc_params=tuple(tuple(mpl.rcParams[key])forkeyin [
13461346
"font.serif","font.sans-serif","font.cursive","font.fantasy",
13471347
"font.monospace"])
1348-
returnself._findfont_cached(
1348+
ret=self._findfont_cached(
13491349
prop,fontext,directory,fallback_to_default,rebuild_if_missing,
13501350
rc_params)
1351+
ifisinstance(ret,Exception):
1352+
raiseret
1353+
returnret
13511354

13521355
defget_font_names(self):
13531356
"""Return the list of available fonts."""
@@ -1496,8 +1499,9 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
14961499
returnself.findfont(default_prop,fontext,directory,
14971500
fallback_to_default=False)
14981501
else:
1499-
raiseValueError(f"Failed to find font{prop}, and fallback "
1500-
f"to the default font was disabled")
1502+
# yes return, exceptions are not cached
1503+
returnValueError(f"Failed to find font{prop}, and fallback "
1504+
f"to the default font was disabled")
15011505
else:
15021506
_log.debug('findfont: Matching %s to %s (%r) with score of %f.',
15031507
prop,best_font.name,best_font.fname,best_score)
@@ -1516,7 +1520,8 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
15161520
returnself.findfont(
15171521
prop,fontext,directory,rebuild_if_missing=False)
15181522
else:
1519-
raiseValueError("No valid font could be found")
1523+
# yes return, exceptions are not cached
1524+
returnValueError("No valid font could be found")
15201525

15211526
return_cached_realpath(result)
15221527

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp