Skip to content

Commit 9869fd7

Browse files
authored
Merge pull request matplotlib#12416 from Kojoley/move-font-cache-rebuild-out-of-exception-handler
MNT: Move font cache rebuild out of exception handler
2 parents 9ffe5d5 + 8d6196e commit 9869fd7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/matplotlib/font_manager.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -1356,17 +1356,20 @@ def _rebuild():
13561356
if _fmcache:
13571357
try:
13581358
fontManager = json_load(_fmcache)
1359+
except FileNotFoundError:
1360+
_log.debug("No font cache found %s", _fmcache)
1361+
except json.JSONDecodeError:
1362+
_log.warning("Font cache parsing failed %s", _fmcache)
1363+
else:
13591364
if (not hasattr(fontManager, '_version') or
13601365
fontManager._version != FontManager.__version__):
1361-
_rebuild()
1366+
_log.debug("Font cache needs rebuild (version mismatch)")
1367+
fontManager = None
13621368
else:
13631369
fontManager.default_size = None
13641370
_log.debug("Using fontManager instance from %s", _fmcache)
1365-
except TimeoutError:
1366-
raise
1367-
except Exception:
1368-
_rebuild()
1369-
else:
1371+
1372+
if fontManager is None:
13701373
_rebuild()
13711374

13721375
def findfont(prop, **kw):

0 commit comments

Comments
 (0)