diff --git a/Lib/fontTools/feaLib/error.py b/Lib/fontTools/feaLib/error.py index e99f5f9ef..8281f959a 100644 --- a/Lib/fontTools/feaLib/error.py +++ b/Lib/fontTools/feaLib/error.py @@ -14,3 +14,7 @@ class FeatureLibError(Exception): return "%s:%d:%d: %s" % (path, line, column, message) else: return message + + +class IncludedFeaNotFound(FeatureLibError): + pass diff --git a/Lib/fontTools/feaLib/lexer.py b/Lib/fontTools/feaLib/lexer.py index 3eccae3fc..5cdd1ba97 100644 --- a/Lib/fontTools/feaLib/lexer.py +++ b/Lib/fontTools/feaLib/lexer.py @@ -1,7 +1,7 @@ from __future__ import print_function, division, absolute_import from __future__ import unicode_literals from fontTools.misc.py23 import * -from fontTools.feaLib.error import FeatureLibError +from fontTools.feaLib.error import FeatureLibError, IncludedFeaNotFound import re import os @@ -231,7 +231,11 @@ class IncludingLexer(object): try: fileobj = open(filename, "r", encoding="utf-8") except IOError as err: - raise FeatureLibError(str(err), location) + # FileNotFoundError does not exist on Python < 3.3 + import errno + if err.errno == errno.ENOENT: + raise IncludedFeaNotFound(str(err), location) + raise # pragma: no cover data = fileobj.read() filename = fileobj.name if hasattr(fileobj, "name") else "" if closing: