Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8d6196e

Browse files
committed
Move font cache rebuild out of exception handler
The purpose of the patch is to make tracebacks from cache rebuilding clearer.
1 parent d99714f commit 8d6196e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/matplotlib/font_manager.py

Lines changed: 9 additions & 6 deletions
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)