From bd2703c54ea42da625b7e521297f9c4e493d86bb Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Fri, 7 Oct 2022 10:24:45 +0200 Subject: partition: return None if partno is unset Undefined values in libfdisk should map to None type in Python. Py_BuildValue("%d", -1); is also incorrectly formatted and raises an error when executed. --- partition.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/partition.c b/partition.c index f1cc5e3..15dd28f 100644 --- a/partition.c +++ b/partition.c @@ -70,8 +70,7 @@ static PyObject *Partition_get_partno(PartitionObject *self) if (fdisk_partition_has_partno(self->pa)) { return PyLong_FromSize_t(fdisk_partition_get_partno(self->pa)); } - // Py_RETURN_NONE; - return Py_BuildValue("%d", -1); + Py_RETURN_NONE; } static PyObject *Partition_get_size(PartitionObject *self) { -- cgit v1.2.3-18-g5258