From 08cf3b12c5feb9717fcb0dfa29f132260e221adc Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 3 Nov 2017 22:47:27 -0700 Subject: [PATCH] Backport PR #9676: FIX: Catch IOError on font-cache write --- 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 f41bc56514cf..89eae9f014e2 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -965,8 +965,10 @@ def json_dump(data, filename): Handles FontManager and its fields.""" with open(filename, 'w') as fh: - json.dump(data, fh, cls=JSONEncoder, indent=2) - + try: + json.dump(data, fh, cls=JSONEncoder, indent=2) + except IOError as e: + warnings.warn('Could not save font_manager cache ', e) def json_load(filename): """Loads a data structure as JSON from the named file.