From d2a379c81af70ec7387463123699c3a13a58b381 Mon Sep 17 00:00:00 2001 From: Jonathan Neuhauser Date: Mon, 14 Jul 2025 13:00:38 +0200 Subject: [PATCH] Don't raise on reversing empty path --- inkex/paths/path.py | 6 +++++- tests/test_inkex_paths.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/inkex/paths/path.py b/inkex/paths/path.py index a9fcf227..d8e3e874 100644 --- a/inkex/paths/path.py +++ b/inkex/paths/path.py @@ -455,7 +455,11 @@ class Path(list): def reverse(self): """Returns a reversed path""" result = Path() - *_, first = self.cend_points + try: + *_, first = self.cend_points + except ValueError: + # Empty path, return empty path + return result closer = None # Go through the path in reverse order diff --git a/tests/test_inkex_paths.py b/tests/test_inkex_paths.py index 76bbe1e4..49897908 100644 --- a/tests/test_inkex_paths.py +++ b/tests/test_inkex_paths.py @@ -797,6 +797,12 @@ class PathTest(TestCase): ret = ret.reverse() self._assertPath(ret, "M 500 500 q -150 -150 -400 -250") + @novector + def test_reverse_empty_path(self): + """Reversing an empty path should not raise an error""" + ret = Path() + ret = ret.reverse() + @novector def test_reverse_multiple_subpaths(self): """Test for https://gitlab.com/inkscape/extensions/-/issues/445. First two -- GitLab