From 157621b886d8a884c590c6f5b300232f39dcf313 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 11 Dec 2015 14:53:16 -0500 Subject: [PATCH] Fix #5660. No FileNotFoundError on Py2 --- lib/matplotlib/dviread.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/dviread.py b/lib/matplotlib/dviread.py index 08885851f64c..665f301f1013 100644 --- a/lib/matplotlib/dviread.py +++ b/lib/matplotlib/dviread.py @@ -451,7 +451,11 @@ def _fnt_def_real(self, k, c, s, d, a, l): fontname = n[-l:].decode('ascii') tfm = _tfmfile(fontname) if tfm is None: - raise FileNotFoundError("missing font metrics file: %s" % fontname) + if six.PY2: + error_class = OSError + else: + error_class = FileNotFoundError + raise error_class("missing font metrics file: %s" % fontname) if c != 0 and tfm.checksum != 0 and c != tfm.checksum: raise ValueError('tfm checksum mismatch: %s' % n)