From c56003892da302934c0ac84a5aea1eaa3b12c994 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 21 Oct 2017 11:35:15 -0700 Subject: [PATCH] Truncate windows registry entries after null byte. --- lib/matplotlib/font_manager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index 7e586f61502a..f9b6d9fb2377 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -226,15 +226,17 @@ def win32InstalledFonts(directory=None, fontext='ttf'): local = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, fontdir) except OSError: continue - if not local: return list_fonts(directory, fontext) try: for j in range(winreg.QueryInfoKey(local)[1]): try: - key, direc, any = winreg.EnumValue( local, j) + key, direc, tp = winreg.EnumValue(local, j) if not isinstance(direc, six.string_types): continue + # Work around for https://bugs.python.org/issue25778, which + # is fixed in Py>=3.6.1. + direc = direc.split("\0", 1)[0] if not os.path.dirname(direc): direc = os.path.join(directory, direc) direc = os.path.abspath(direc).lower()