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
parent
ef613790e9
commit
b905c1996f
1
fdisk.c
1
fdisk.c
|
@ -65,6 +65,7 @@ PyInit_fdisk(void)
|
|||
|
||||
Context_AddModuleObject(m);
|
||||
Label_AddModuleObject(m);
|
||||
Partition_AddModuleObject(m);
|
||||
|
||||
|
||||
return m;
|
||||
|
|
1
fdisk.h
1
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);
|
||||
|
|
Loading…
Reference in New Issue