booleanOperations library: remove unreachable break and add exception instead of assertion, as done in upstream

This commit is contained in:
Rasmus Andersson 2018-01-23 19:05:54 -08:00
parent 632609fc65
commit 0d7d370104
2 changed files with 7 additions and 2 deletions

View file

@ -19,3 +19,7 @@ class InvalidClippingContourError(InvalidContourError):
class ExecutionError(BooleanOperationsError): class ExecutionError(BooleanOperationsError):
"""Raised when clipping execution fails""" """Raised when clipping execution fails"""
class OpenContourError(BooleanOperationsError):
"""Raised when any input contour is open"""

View file

@ -3,6 +3,7 @@ import math
from fontTools.misc import bezierTools from fontTools.misc import bezierTools
from fontTools.pens.basePen import decomposeQuadraticSegment from fontTools.pens.basePen import decomposeQuadraticSegment
import pyclipper import pyclipper
from .exceptions import OpenContourError
""" """
To Do: To Do:
@ -343,7 +344,8 @@ class ContourPointDataPen:
pass pass
def addPoint(self, pt, segmentType=None, smooth=False, name=None, **kwargs): 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: if not self._foundStartingPoint and segmentType is not None:
kwargs['startingPoint'] = self._foundStartingPoint = True kwargs['startingPoint'] = self._foundStartingPoint = True
data = InputPoint( data = InputPoint(
@ -373,7 +375,6 @@ def _prepPointsForSegments(points):
point = points.pop() point = points.pop()
points.insert(0, point) points.insert(0, point)
continue continue
break
def _copyPoints(points): def _copyPoints(points):