From 0d7d370104a61ca831b8b04bba9348aed45ae6c5 Mon Sep 17 00:00:00 2001 From: Rasmus Andersson Date: Tue, 23 Jan 2018 19:05:54 -0800 Subject: [PATCH] booleanOperations library: remove unreachable break and add exception instead of assertion, as done in upstream --- misc/pylib/booleanOperations/exceptions.py | 4 ++++ misc/pylib/booleanOperations/flatten.pyx | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/misc/pylib/booleanOperations/exceptions.py b/misc/pylib/booleanOperations/exceptions.py index 23028b207..38b72e0b2 100644 --- a/misc/pylib/booleanOperations/exceptions.py +++ b/misc/pylib/booleanOperations/exceptions.py @@ -19,3 +19,7 @@ class InvalidClippingContourError(InvalidContourError): class ExecutionError(BooleanOperationsError): """Raised when clipping execution fails""" + + +class OpenContourError(BooleanOperationsError): + """Raised when any input contour is open""" diff --git a/misc/pylib/booleanOperations/flatten.pyx b/misc/pylib/booleanOperations/flatten.pyx index 85b54a03d..606b2005a 100644 --- a/misc/pylib/booleanOperations/flatten.pyx +++ b/misc/pylib/booleanOperations/flatten.pyx @@ -3,6 +3,7 @@ import math from fontTools.misc import bezierTools from fontTools.pens.basePen import decomposeQuadraticSegment import pyclipper +from .exceptions import OpenContourError """ To Do: @@ -343,7 +344,8 @@ class ContourPointDataPen: pass def addPoint(self, pt, segmentType=None, smooth=False, name=None, **kwargs): - assert segmentType != "move" + if segmentType == "move": + raise OpenContourError("Unhandled open contour") if not self._foundStartingPoint and segmentType is not None: kwargs['startingPoint'] = self._foundStartingPoint = True data = InputPoint( @@ -373,7 +375,6 @@ def _prepPointsForSegments(points): point = points.pop() points.insert(0, point) continue - break def _copyPoints(points):