From 20c93b9fdb005e89ffd39240adb2ba39e1f9762f Mon Sep 17 00:00:00 2001 From: justvanrossum Date: Sun, 17 Mar 2019 18:18:10 +0100 Subject: [PATCH] use RecursionError, and provide an alias for RuntimeError for Py2 --- Lib/fontTools/misc/py23.py | 8 +++++++- Lib/fontTools/ttLib/tables/_g_l_y_f.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/fontTools/misc/py23.py b/Lib/fontTools/misc/py23.py index 37020555e..5cddfebca 100644 --- a/Lib/fontTools/misc/py23.py +++ b/Lib/fontTools/misc/py23.py @@ -7,7 +7,7 @@ import sys __all__ = ['basestring', 'unicode', 'unichr', 'byteord', 'bytechr', 'BytesIO', 'StringIO', 'UnicodeIO', 'strjoin', 'bytesjoin', 'tobytes', 'tostr', 'tounicode', 'Tag', 'open', 'range', 'xrange', 'round', 'Py23Error', - 'SimpleNamespace', 'zip'] + 'SimpleNamespace', 'zip', 'RecursionError'] class Py23Error(NotImplementedError): @@ -514,6 +514,12 @@ else: _stream = "stderr" +try: + RecursionError = RecursionError +except NameError: + RecursionError = RuntimeError + + if __name__ == "__main__": import doctest, sys sys.exit(doctest.testmod().failed) diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index 4a629230e..b8020ca7b 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -843,7 +843,7 @@ class Glyph(object): g = glyfTable[compo.glyphName] try: coordinates, endPts, flags = g.getCoordinates(glyfTable) - except RuntimeError: + except RecursionError: raise ttLib.TTLibError("glyph '%s' contains a recursive component reference" % compo.glyphName) if hasattr(compo, "firstPt"): # move according to two reference points