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

Skip to content

Commit 4afcaac

Browse files
committed
Don't error if some font directories are not readable.
1 parent 9cffe0e commit 4afcaac

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/font_manager.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ def list_fonts(directory, extensions):
152152
recursively under the directory.
153153
"""
154154
extensions = ["." + ext for ext in extensions]
155-
return [str(path)
156-
for path in filter(Path.is_file, Path(directory).glob("**/*.*"))
157-
if path.suffix.lower() in extensions]
155+
return [filename
156+
# os.walk ignores access errors, unlike Path.glob.
157+
for _, _, filenames in os.walk(directory)
158+
for filename in filenames
159+
if Path(filename).suffix.lower() in extensions]
158160

159161

160162
def win32FontDirectory():

0 commit comments

Comments
 (0)