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

Skip to content

Commit 416495b

Browse files
authored
Merge pull request #12408 from anntzer/lenient-winfontmanager
Don't crash on invalid registry font entries on Windows.
2 parents 13629a4 + 9728777 commit 416495b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/matplotlib/font_manager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,12 @@ def win32InstalledFonts(directory=None, fontext='ttf'):
199199
# Work around for https://bugs.python.org/issue25778, which
200200
# is fixed in Py>=3.6.1.
201201
direc = direc.split("\0", 1)[0]
202-
path = Path(directory, direc).resolve()
202+
try:
203+
path = Path(directory, direc).resolve()
204+
except (FileNotFoundError, RuntimeError):
205+
# Don't fail with invalid entries (FileNotFoundError is
206+
# only necessary on Py3.5).
207+
continue
203208
if path.suffix.lower() in fontext:
204209
items.add(str(path))
205210
except (OSError, MemoryError):

0 commit comments

Comments
 (0)