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'
master
Jose M. Guisado Gomez 2022-04-26 17:08:49 +02:00
parent ef613790e9
commit b905c1996f
2 changed files with 2 additions and 0 deletions

View File

@ -65,6 +65,7 @@ PyInit_fdisk(void)
Context_AddModuleObject(m);
Label_AddModuleObject(m);
Partition_AddModuleObject(m);
return m;

View File

@ -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);