Skip to content

Commit

Permalink
🐛 Don't crash when outputting an empty path object
Browse files Browse the repository at this point in the history
Previously, applying `str` or `repr` to an object representing the
path `<path d="">` would abort with an AttributeError because the
bounding box is None, which does not support the `center` method.
Now, we use (NaN, NaN) as the center of an empty path.
  • Loading branch information
spakin committed Feb 1, 2024
1 parent 9784376 commit f446921
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions simpinkscr/simple_inkscape_scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ def __repr__(self):
'Return a unique description of the object as a string.'
iobj = self.get_inkex_object()
bbox = iobj.bounding_box()
if bbox is None:
# Make empty paths produce a center of (NaN, NaN) instead
# of crashing with an AttributeError.
bbox = inkex.BoundingBox()
return '<%s %s (%s) %s>' % \
(self.__class__.__name__,
iobj.TAG,
Expand Down

0 comments on commit f446921

Please sign in to comment.