From c459cf4e9f4989cdb44c2246a20fc7590bd68eee Mon Sep 17 00:00:00 2001 From: Nikita Kniazev Date: Sun, 22 Oct 2017 19:58:20 +0300 Subject: [PATCH] Backport PR #9504: 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 9602db76c9fd..f41bc56514cf 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()