Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Tests/test_imagepath.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ def test_overflow_segfault() -> None:
x[i] = b"0" * 16


def test_compact_empty_path() -> None:
p = ImagePath.Path(0)
assert p.compact() == 0


def test_compact_within_map() -> None:
p = ImagePath.Path([0, 1])

Expand Down
4 changes: 4 additions & 0 deletions src/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ path_compact(PyPathObject *self, PyObject *args) {
PyErr_SetString(PyExc_ValueError, "Path compacted during mapping");
return NULL;
}
if (self->count == 0) {
// no points to remove
return Py_BuildValue("i", 0);
}
if (!PyArg_ParseTuple(args, "|d:compact", &cityblock)) {
return NULL;
}
Expand Down
Loading