From b905c1996fa2b894631949dffb60b03a9c7c3412 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado Gomez" Date: Tue, 26 Apr 2022 17:08:49 +0200 Subject: fdisk.c: add partition module object Call Partition_AddModuleObject when initializing the python module. Fixes bug when using the Partition class but the class has not been added to the module via Py_TypeReady. A common error was the type not being ready (missing attributes): >>> for pa in cxt.parts: ... print(pa.partno) ... Traceback (most recent call last): File "", line 2, in AttributeError: 'libfdisk.Partition' object has no attribute 'partno' --- fdisk.c | 1 + fdisk.h | 1 + 2 files changed, 2 insertions(+) diff --git a/fdisk.c b/fdisk.c index 89e4cff..c44b2f1 100644 --- a/fdisk.c +++ b/fdisk.c @@ -65,6 +65,7 @@ PyInit_fdisk(void) Context_AddModuleObject(m); Label_AddModuleObject(m); + Partition_AddModuleObject(m); return m; diff --git a/fdisk.h b/fdisk.h index 9e01baf..496b6f7 100644 --- a/fdisk.h +++ b/fdisk.h @@ -44,6 +44,7 @@ extern PyTypeObject PartitionType; extern void Context_AddModuleObject(PyObject *mod); extern void Label_AddModuleObject(PyObject *mod); +extern void Partition_AddModuleObject(PyObject *mod); extern PyObject *PyObjectResultStr(const char *s); extern PyObject *PyObjectResultLabel(struct fdisk_label *lb); -- cgit v1.2.3-18-g5258