summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose M. Guisado Gomez <guigom@riseup.net>2022-04-26 17:08:49 +0200
committerJose M. Guisado Gomez <guigom@riseup.net>2022-04-26 17:08:49 +0200
commitb905c1996fa2b894631949dffb60b03a9c7c3412 (patch)
treeee1f3a7687edcd59881cdea45cc9393c094dea77
parentef613790e9f6ecc52455b70d1c711266b9e3c96f (diff)
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 "<stdin>", line 2, in <module> AttributeError: 'libfdisk.Partition' object has no attribute 'partno'
-rw-r--r--fdisk.c1
-rw-r--r--fdisk.h1
2 files changed, 2 insertions, 0 deletions
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);