use RecursionError, and provide an alias for RuntimeError for Py2

This commit is contained in:
justvanrossum 2019-03-17 18:18:10 +01:00
parent 12ec7f539e
commit 20c93b9fdb
2 changed files with 8 additions and 2 deletions

View File

@ -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)

View File

@ -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