From 9728777345489074b29ebf1e9616f9f0e8f2f38c Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 5 Oct 2018 14:38:52 +0200 Subject: [PATCH] Don't crash on invalid registry font entries on Windows. --- lib/matplotlib/font_manager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index 887f61f9398d..3d72bc9bd5c0 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -199,7 +199,12 @@ def win32InstalledFonts(directory=None, fontext='ttf'): # Work around for https://bugs.python.org/issue25778, which # is fixed in Py>=3.6.1. direc = direc.split("\0", 1)[0] - path = Path(directory, direc).resolve() + try: + path = Path(directory, direc).resolve() + except (FileNotFoundError, RuntimeError): + # Don't fail with invalid entries (FileNotFoundError is + # only necessary on Py3.5). + continue if path.suffix.lower() in fontext: items.add(str(path)) except (OSError, MemoryError):