From f3f50393a8098c458f28d9d505fbf449e02d3b5d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 2 Feb 2023 10:52:31 -0700 Subject: [PATCH] [ttGlyph] Adjust contextmanager pattern --- Lib/fontTools/ttLib/ttGlyphSet.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/fontTools/ttLib/ttGlyphSet.py b/Lib/fontTools/ttLib/ttGlyphSet.py index 1b02b975d..753aa0cbc 100644 --- a/Lib/fontTools/ttLib/ttGlyphSet.py +++ b/Lib/fontTools/ttLib/ttGlyphSet.py @@ -45,9 +45,10 @@ class _TTGlyphSet(Mapping): self.location = self.location.copy() self.location.update(location) - yield None - - self.location = self.locationStack.pop() + try: + yield None + finally: + self.location = self.locationStack.pop() def __contains__(self, glyphName): return glyphName in self.glyphsMapping