a04203
diff -up pyparted-3.11.7/src/pydisk.c.orig pyparted-3.11.7/src/pydisk.c
a04203
--- pyparted-3.11.7/src/pydisk.c.orig	2019-04-23 14:23:44.456665800 -0400
a04203
+++ pyparted-3.11.7/src/pydisk.c	2021-07-09 15:59:00.998981206 -0400
a04203
@@ -205,8 +205,7 @@ int _ped_Partition_init(_ped_Partition *
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(PartitionException, partedExnMessage);
a04203
             }
a04203
         } else {
a04203
@@ -423,8 +422,7 @@ int _ped_Disk_init(_ped_Disk *self, PyOb
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(DiskLabelException, partedExnMessage);
a04203
             }
a04203
         } else {
a04203
@@ -548,6 +546,7 @@ PyObject *py_ped_disk_type_get_next(PyOb
a04203
     }
a04203
 
a04203
     next = ped_disk_type_get_next(cur);
a04203
+
a04203
     if (next) {
a04203
         ret = PedDiskType2_ped_DiskType(next);
a04203
         return (PyObject *) ret;
a04203
@@ -575,6 +574,7 @@ PyObject *py_ped_disk_type_get(PyObject
a04203
         }
a04203
 
a04203
         ret = PedDiskType2_ped_DiskType(out_type);
a04203
+
a04203
         if (ret == NULL) {
a04203
             return NULL;
a04203
         }
a04203
@@ -590,16 +590,14 @@ PyObject *py_ped_disk_type_check_feature
a04203
     int ret = 0;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "i", &feature)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     disktype = _ped_DiskType2PedDiskType(s);
a04203
+
a04203
     if (disktype) {
a04203
         ret = ped_disk_type_check_feature(disktype, feature);
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
-    }
a04203
 
a04203
     if (ret) {
a04203
         Py_RETURN_TRUE;
a04203
@@ -613,29 +611,28 @@ PyObject *py_ped_disk_clobber(PyObject *
a04203
     int ret = 0;
a04203
 
a04203
     device = _ped_Device2PedDevice(s);
a04203
-    if (device == NULL)
a04203
-        return NULL;
a04203
+
a04203
+    if (device == NULL) {
a04203
+        return (PyObject *) NULL;
a04203
+    }
a04203
 
a04203
     ret = ped_disk_clobber(device);
a04203
+
a04203
     if (ret == 0) {
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(IOException, partedExnMessage);
a04203
-        }
a04203
-        else
a04203
+            }
a04203
+        } else {
a04203
             PyErr_Format(DiskException, "Failed to clobber partition table on device %s", device->path);
a04203
+        }
a04203
 
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
-    if (ret) {
a04203
-        Py_RETURN_TRUE;
a04203
-    } else {
a04203
-        Py_RETURN_FALSE;
a04203
-    }
a04203
+    Py_RETURN_TRUE;
a04203
 }
a04203
 
a04203
 /* XXX: is this necessary? */
a04203
@@ -644,18 +641,20 @@ PyObject *py_ped_disk_duplicate(PyObject
a04203
     _ped_Disk *ret = NULL;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         pass_disk = ped_disk_duplicate(disk);
a04203
+
a04203
         if (pass_disk == NULL) {
a04203
             if (partedExnRaised) {
a04203
                 partedExnRaised = 0;
a04203
 
a04203
-                if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                    !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+                if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                     PyErr_SetString(IOException, partedExnMessage);
a04203
-            }
a04203
-            else
a04203
+                }
a04203
+            } else {
a04203
                 PyErr_Format(DiskException, "Could not duplicate device %s", disk->dev->path);
a04203
+            }
a04203
 
a04203
             return NULL;
a04203
         }
a04203
@@ -664,8 +663,7 @@ PyObject *py_ped_disk_duplicate(PyObject
a04203
         if (ret == NULL) {
a04203
             return NULL;
a04203
         }
a04203
-    }
a04203
-    else {
a04203
+    } else {
a04203
         return NULL;
a04203
     }
a04203
 
a04203
@@ -685,8 +683,9 @@ PyObject *py_ped_disk_destroy(PyObject *
a04203
     PedDisk *disk = NULL;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ped_disk_destroy(disk);
a04203
@@ -701,26 +700,24 @@ PyObject *py_ped_disk_commit(PyObject *s
a04203
     int ret = 0;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         ret = ped_disk_commit(disk);
a04203
+
a04203
         if (ret == 0) {
a04203
             if (partedExnRaised) {
a04203
                 partedExnRaised = 0;
a04203
 
a04203
-                if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                    !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+                if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                     PyErr_SetString(IOException, partedExnMessage);
a04203
+                }
a04203
+            } else {
a04203
+                PyErr_Format(DiskException, "Could not commit to disk %s, (%s)", disk->dev->path, __func__);
a04203
             }
a04203
-            else
a04203
-                PyErr_Format(DiskException, "Could not commit to disk %s, (%s)",
a04203
-                             disk->dev->path, __func__);
a04203
 
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
-    }
a04203
 
a04203
     if (ret) {
a04203
         Py_RETURN_TRUE;
a04203
@@ -734,26 +731,24 @@ PyObject *py_ped_disk_commit_to_dev(PyOb
a04203
     int ret = 0;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         ret = ped_disk_commit_to_dev(disk);
a04203
+
a04203
         if (ret == 0) {
a04203
             if (partedExnRaised) {
a04203
                 partedExnRaised = 0;
a04203
 
a04203
-                if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                    !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+                if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                     PyErr_SetString(IOException, partedExnMessage);
a04203
+                }
a04203
+            } else {
a04203
+                PyErr_Format(DiskException, "Could not commit to disk %s, (%s)", disk->dev->path, __func__);
a04203
             }
a04203
-            else
a04203
-                PyErr_Format(DiskException, "Could not commit to disk %s, (%s)",
a04203
-                             disk->dev->path, __func__);
a04203
 
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
-    }
a04203
 
a04203
     if (ret) {
a04203
         Py_RETURN_TRUE;
a04203
@@ -773,20 +768,16 @@ PyObject *py_ped_disk_commit_to_os(PyObj
a04203
             if (partedExnRaised) {
a04203
                 partedExnRaised = 0;
a04203
 
a04203
-                if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                    !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+                if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                     PyErr_SetString(IOException, partedExnMessage);
a04203
+                }
a04203
+            } else {
a04203
+                PyErr_Format(DiskException, "Could not commit to disk %s, (%s)", disk->dev->path, __func__);
a04203
             }
a04203
-            else
a04203
-                PyErr_Format(DiskException, "Could not commit to disk %s, (%s)",
a04203
-                             disk->dev->path, __func__);
a04203
 
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
-    }
a04203
 
a04203
     if (ret) {
a04203
         Py_RETURN_TRUE;
a04203
@@ -800,25 +791,24 @@ PyObject *py_ped_disk_check(PyObject *s,
a04203
     int ret = 0;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         ret = ped_disk_check(disk);
a04203
+
a04203
         if (ret == 0) {
a04203
             if (partedExnRaised) {
a04203
                 partedExnRaised = 0;
a04203
 
a04203
-                if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                    !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+                if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                     PyErr_SetString(IOException, partedExnMessage);
a04203
-            }
a04203
-            else
a04203
+                }
a04203
+            } else {
a04203
                 PyErr_Format(DiskException, "Could not check disk %s", disk->dev->path);
a04203
+            }
a04203
 
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
-    }
a04203
 
a04203
     if (ret) {
a04203
         Py_RETURN_TRUE;
a04203
@@ -831,12 +821,10 @@ PyObject *py_ped_disk_print(PyObject *s,
a04203
     PedDisk *disk = NULL;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         ped_disk_print(disk);
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
-    }
a04203
 
a04203
     Py_INCREF(Py_None);
a04203
     return Py_None;
a04203
@@ -847,12 +835,10 @@ PyObject *py_ped_disk_get_primary_partit
a04203
     int ret = 0;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         ret = ped_disk_get_primary_partition_count(disk);
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
-    }
a04203
 
a04203
     return PyLong_FromLong(ret);
a04203
 }
a04203
@@ -862,38 +848,33 @@ PyObject *py_ped_disk_get_last_partition
a04203
     int ret = 0;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         ret = ped_disk_get_last_partition_num(disk);
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
-    }
a04203
 
a04203
     return PyLong_FromLong(ret);
a04203
 }
a04203
 
a04203
-PyObject *py_ped_disk_get_max_primary_partition_count(PyObject *s,
a04203
-                                                      PyObject *args) {
a04203
+PyObject *py_ped_disk_get_max_primary_partition_count(PyObject *s, PyObject *args) {
a04203
     PedDisk *disk = NULL;
a04203
     int ret = 0;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         ret = ped_disk_get_max_primary_partition_count(disk);
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
-    }
a04203
 
a04203
     return PyLong_FromLong(ret);
a04203
 }
a04203
 
a04203
-PyObject *py_ped_disk_get_max_supported_partition_count(PyObject *s,
a04203
-                                                        PyObject *args) {
a04203
+PyObject *py_ped_disk_get_max_supported_partition_count(PyObject *s, PyObject *args) {
a04203
     PedDisk *disk = NULL;
a04203
     int max = 0;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         if (ped_disk_get_max_supported_partition_count(disk, &max) == true) {
a04203
             return Py_BuildValue("i", max);
a04203
@@ -910,13 +891,16 @@ PyObject *py_ped_disk_get_partition_alig
a04203
     _ped_Alignment *ret = NULL;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
-    if (!disk)
a04203
-        return NULL;
a04203
+
a04203
+    if (!disk) {
a04203
+        return (PyObject *) NULL;
a04203
+    }
a04203
 
a04203
     alignment = ped_disk_get_partition_alignment(disk);
a04203
+
a04203
     if (!alignment) {
a04203
         PyErr_SetString(CreateException, "Could not get alignment for device");
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret = PedAlignment2_ped_Alignment(alignment);
a04203
@@ -929,8 +913,10 @@ PyObject *py_ped_disk_max_partition_leng
a04203
     PedDisk *disk = NULL;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
-    if (!disk)
a04203
-        return NULL;
a04203
+
a04203
+    if (!disk) {
a04203
+        return (PyObject *) NULL;
a04203
+    }
a04203
 
a04203
     return PyLong_FromUnsignedLongLong(ped_disk_max_partition_length(disk));
a04203
 }
a04203
@@ -939,8 +925,10 @@ PyObject *py_ped_disk_max_partition_star
a04203
     PedDisk *disk = NULL;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
-    if (!disk)
a04203
-        return NULL;
a04203
+
a04203
+    if (!disk) {
a04203
+        return (PyObject *) NULL;
a04203
+    }
a04203
 
a04203
     return PyLong_FromUnsignedLongLong(ped_disk_max_partition_start_sector(disk));
a04203
 }
a04203
@@ -950,27 +938,29 @@ PyObject *py_ped_disk_set_flag(PyObject
a04203
     PedDisk *disk = NULL;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "ii", &flag, &state)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret = ped_disk_set_flag(disk, flag, state);
a04203
+
a04203
     if (ret == 0) {
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(DiskException, partedExnMessage);
a04203
-        }
a04203
-        else
a04203
+            }
a04203
+        } else {
a04203
             PyErr_Format(DiskException, "Could not set flag on disk %s", disk->dev->path);
a04203
+        }
a04203
 
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     Py_RETURN_TRUE;
a04203
@@ -981,12 +971,13 @@ PyObject *py_ped_disk_get_flag(PyObject
a04203
     PedDisk *disk = NULL;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "i", &flag)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (ped_disk_get_flag(disk, flag)) {
a04203
@@ -1001,12 +992,13 @@ PyObject *py_ped_disk_is_flag_available(
a04203
     PedDisk *disk = NULL;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "i", &flag)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (ped_disk_is_flag_available(disk, flag)) {
a04203
@@ -1021,27 +1013,28 @@ PyObject *py_ped_disk_flag_get_name(PyOb
a04203
     char *ret = NULL;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "i", &flag)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (flag < PED_DISK_FIRST_FLAG) {
a04203
         PyErr_SetString(PyExc_ValueError, "Invalid flag provided.");
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret = (char *) ped_disk_flag_get_name(flag);
a04203
+
a04203
     if (ret == NULL) {
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(DiskException, partedExnMessage);
a04203
-        }
a04203
-        else
a04203
+            }
a04203
+        } else {
a04203
             PyErr_Format(DiskException, "Could not get disk flag name for %d", flag);
a04203
+        }
a04203
 
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     return PyUnicode_FromString(ret);
a04203
@@ -1051,7 +1044,7 @@ PyObject *py_ped_disk_flag_get_by_name(P
a04203
     char *name = NULL;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "s", &name)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     return PyLong_FromLong(ped_disk_flag_get_by_name(name));
a04203
@@ -1061,7 +1054,7 @@ PyObject *py_ped_disk_flag_next(PyObject
a04203
     int flag;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "i", &flag)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     return Py_BuildValue("i", ped_disk_flag_next(flag));
a04203
@@ -1080,8 +1073,9 @@ PyObject *py_ped_partition_destroy(_ped_
a04203
     PedPartition *partition = NULL;
a04203
 
a04203
     partition = _ped_Partition2PedPartition(s);
a04203
+
a04203
     if (partition == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ped_partition_destroy(partition);
a04203
@@ -1096,12 +1090,10 @@ PyObject *py_ped_partition_is_active(_pe
a04203
     int ret = 0;
a04203
 
a04203
     partition = _ped_Partition2PedPartition(s);
a04203
+
a04203
     if (partition) {
a04203
         ret = ped_partition_is_active(partition);
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
-    }
a04203
 
a04203
     if (ret) {
a04203
         Py_RETURN_TRUE;
a04203
@@ -1117,28 +1109,30 @@ PyObject *py_ped_partition_set_flag(_ped
a04203
     int ret = 0;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "ii", &flag, &in_state)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     part = _ped_Partition2PedPartition(s);
a04203
+
a04203
     if (part == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (part && flag && in_state > -1) {
a04203
         ret = ped_partition_set_flag(part, flag, in_state);
a04203
+
a04203
         if (ret == 0) {
a04203
             if (partedExnRaised) {
a04203
                 partedExnRaised = 0;
a04203
 
a04203
-                if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                    !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+                if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                     PyErr_SetString(PartitionException, partedExnMessage);
a04203
-            }
a04203
-            else
a04203
+                }
a04203
+            } else {
a04203
                 PyErr_Format(PartitionException, "Could not set flag on partition %s%d", part->disk->dev->path, part->num);
a04203
+            }
a04203
 
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
 
a04203
@@ -1155,18 +1149,19 @@ PyObject *py_ped_partition_get_flag(_ped
a04203
     int ret = -1;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "i", &flag)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     part = _ped_Partition2PedPartition(s);
a04203
+
a04203
     if (part == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     /* ped_partition_get_flag will assert on this. */
a04203
     if (!ped_partition_is_active(part)) {
a04203
         PyErr_Format(PartitionException, "Could not get flag on inactive partition %s%d", part->disk->dev->path, part->num);
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret = ped_partition_get_flag(part, flag);
a04203
@@ -1184,17 +1179,18 @@ PyObject *py_ped_partition_is_flag_avail
a04203
     int ret = 0;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "i", &flag)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     part = _ped_Partition2PedPartition(s);
a04203
+
a04203
     if (part == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (!ped_partition_is_active(part)) {
a04203
         PyErr_Format(PartitionException, "Flag is not available on inactive partition %s%d", part->disk->dev->path, part->num);
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret = ped_partition_is_flag_available(part, flag);
a04203
@@ -1213,31 +1209,34 @@ PyObject *py_ped_partition_set_system(_p
a04203
     int ret = 0;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "O!", &_ped_FileSystemType_Type_obj, &in_fstype)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     part = _ped_Partition2PedPartition(s);
a04203
+
a04203
     if (part == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (in_fstype != NULL) {
a04203
         out_fstype = _ped_FileSystemType2PedFileSystemType(in_fstype);
a04203
+
a04203
         if (out_fstype == NULL) {
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
 
a04203
     /* ped_partition_set_system will assert on this. */
a04203
     if (!ped_partition_is_active(part)) {
a04203
         PyErr_Format(PartitionException, "Could not set system flag on inactive partition %s%d", part->disk->dev->path, part->num);
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret = ped_partition_set_system(part, out_fstype);
a04203
+
a04203
     if (ret == 0) {
a04203
         PyErr_Format(PartitionException, "Could not set system flag on partition %s%d", part->disk->dev->path, part->num);
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (ret) {
a04203
@@ -1253,34 +1252,35 @@ PyObject *py_ped_partition_set_name(_ped
a04203
     int ret = 0;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "s", &in_name)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     part = _ped_Partition2PedPartition(s);
a04203
+
a04203
     if (part == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     /* ped_partition_set_name will assert on this. */
a04203
     if (!ped_partition_is_active(part)) {
a04203
         PyErr_Format(PartitionException, "Could not set system flag on inactive partition %s%d", part->disk->dev->path, part->num);
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret = ped_partition_set_name(part, in_name);
a04203
+
a04203
     if (ret == 0) {
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(PartitionException, partedExnMessage);
a04203
             }
a04203
         } else {
a04203
             PyErr_Format(PartitionException, "Could not set name on partition %s%d", part->disk->dev->path, part->num);
a04203
         }
a04203
 
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (ret) {
a04203
@@ -1295,30 +1295,31 @@ PyObject *py_ped_partition_get_name(_ped
a04203
     char *ret = NULL;
a04203
 
a04203
     part = _ped_Partition2PedPartition(s);
a04203
+
a04203
     if (part == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     /* ped_partition_get_name will assert on this. */
a04203
     if (!ped_partition_is_active(part)) {
a04203
         PyErr_Format(PartitionException, "Could not get name on inactive partition %s%d", part->disk->dev->path, part->num);
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret = (char *) ped_partition_get_name(part);
a04203
+
a04203
     if (ret == NULL) {
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(PartitionException, partedExnMessage);
a04203
             }
a04203
         } else {
a04203
             PyErr_Format(PartitionException, "Could not read name on partition %s%d", part->disk->dev->path, part->num);
a04203
         }
a04203
 
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     return PyUnicode_FromString(ret);
a04203
@@ -1329,13 +1330,13 @@ PyObject *py_ped_partition_is_busy(_ped_
a04203
     int ret = 0;
a04203
 
a04203
     part = _ped_Partition2PedPartition(s);
a04203
-    if (part) {
a04203
-        ret = ped_partition_is_busy(part);
a04203
-    }
a04203
-    else {
a04203
-        return NULL;
a04203
+
a04203
+    if (part == NULL) {
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
+    ret = ped_partition_is_busy(part);
a04203
+
a04203
     if (ret) {
a04203
         Py_RETURN_TRUE;
a04203
     } else {
a04203
@@ -1348,15 +1349,16 @@ PyObject *py_ped_partition_get_path(_ped
a04203
     char *ret = NULL;
a04203
 
a04203
     part = _ped_Partition2PedPartition(s);
a04203
-    if (part) {
a04203
-        ret = ped_partition_get_path(part);
a04203
-        if (ret == NULL) {
a04203
-            PyErr_Format(PartitionException, "Could not get path for partition %s%d", part->disk->dev->path, part->num);
a04203
-            return NULL;
a04203
-        }
a04203
+
a04203
+    if (part == NULL) {
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
+
a04203
+    ret = ped_partition_get_path(part);
a04203
+
a04203
+    if (ret == NULL) {
a04203
+        PyErr_Format(PartitionException, "Could not get path for partition %s%d", part->disk->dev->path, part->num);
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     return PyUnicode_FromString(ret);
a04203
@@ -1366,12 +1368,12 @@ PyObject *py_ped_partition_reset_num(_pe
a04203
     PedPartition *part = NULL;
a04203
 
a04203
     part = _ped_Partition2PedPartition(s);
a04203
+
a04203
     if (part == NULL) {
a04203
-        Py_RETURN_FALSE;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     part->num = -1;
a04203
-
a04203
     Py_RETURN_TRUE;
a04203
 }
a04203
 
a04203
@@ -1381,17 +1383,18 @@ PyObject *py_ped_partition_type_get_name
a04203
     char *ret = NULL;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "i", &type)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (type) {
a04203
         ret = (char *) ped_partition_type_get_name(type);
a04203
     }
a04203
 
a04203
-    if (ret != NULL)
a04203
+    if (ret != NULL) {
a04203
         return PyUnicode_FromString(ret);
a04203
-    else
a04203
-        return PyUnicode_FromString("");
a04203
+    } else {
a04203
+        return (PyObject *) NULL;
a04203
+    }
a04203
 }
a04203
 
a04203
 PyObject *py_ped_partition_flag_get_name(PyObject *s, PyObject *args) {
a04203
@@ -1399,12 +1402,12 @@ PyObject *py_ped_partition_flag_get_name
a04203
     char *ret = NULL;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "i", &flag)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (flag < PED_PARTITION_FIRST_FLAG) {
a04203
         PyErr_SetString(PyExc_ValueError, "Invalid flag provided.");
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (flag) {
a04203
@@ -1413,7 +1416,7 @@ PyObject *py_ped_partition_flag_get_name
a04203
         if (!ret) {
a04203
             /* Re-raise the libparted exception. */
a04203
             partedExnRaised = 0;
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
 
a04203
@@ -1424,7 +1427,7 @@ PyObject *py_ped_partition_flag_get_by_n
a04203
     char *name = NULL;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "s", &name)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     return PyLong_FromLong(ped_partition_flag_get_by_name(name));
a04203
@@ -1434,7 +1437,7 @@ PyObject *py_ped_partition_flag_next(PyO
a04203
     int flag;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "i", &flag)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     return Py_BuildValue("i", ped_partition_flag_next(flag));
a04203
@@ -1448,38 +1451,40 @@ PyObject *py_ped_disk_add_partition(PyOb
a04203
     PedConstraint *out_constraint = NULL;
a04203
     int ret = 0;
a04203
 
a04203
-    if (!PyArg_ParseTuple(args, "O!|O!",&_ped_Partition_Type_obj,
a04203
-                          &in_part, &_ped_Constraint_Type_obj, &in_constraint)) {
a04203
-        return NULL;
a04203
+    if (!PyArg_ParseTuple(args, "O!|O!",&_ped_Partition_Type_obj, &in_part, &_ped_Constraint_Type_obj, &in_constraint)) {
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     /* Its non-sense to add an owned partition */
a04203
     if (in_part->_owned == 1) {
a04203
         PyErr_SetString(PartitionException, "Attempting to add a partition "
a04203
                                             "that is already owned by a disk.");
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
 
a04203
     out_part = _ped_Partition2PedPartition(in_part);
a04203
+
a04203
     if (out_part == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (out_part->disk != disk) {
a04203
         PyErr_SetString(PartitionException, "Cannot add a partition to another disk then the one used for creating the partition");
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (in_constraint) {
a04203
         out_constraint = _ped_Constraint2PedConstraint(in_constraint);
a04203
+
a04203
         if (out_constraint == NULL) {
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
 
a04203
@@ -1492,14 +1497,14 @@ PyObject *py_ped_disk_add_partition(PyOb
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(PartitionException, partedExnMessage);
a04203
-        }
a04203
-        else
a04203
+            }
a04203
+        } else {
a04203
             PyErr_Format(PartitionException, "Could not create partition %s%d", out_part->disk->dev->path, out_part->num);
a04203
+        }
a04203
 
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     /* update our _ped.Partition object with out_part values */
a04203
@@ -1521,56 +1526,62 @@ PyObject *py_ped_disk_remove_partition(P
a04203
     int ret = 0;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "O!", &_ped_Partition_Type_obj, &in_part)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     /* Its non-sense  to remove an unowned partition */
a04203
     if (in_part->_owned == 0) {
a04203
         PyErr_SetString(PartitionException, "Attempting to remove a partition "
a04203
                                             "that is not owned by any disk.");
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     out_part = _ped_Partition2PedPartition(in_part);
a04203
+
a04203
     if (out_part == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (out_part->disk != disk) {
a04203
         PyErr_SetString(PartitionException, "Partition is not part of the disk it is being removed from");
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (out_part->part_list != NULL) {
a04203
         PedPartition *part;
a04203
+
a04203
         for (part = out_part->part_list; part; part = part->next) {
a04203
-            if (ped_partition_is_active(part))
a04203
+            if (ped_partition_is_active(part)) {
a04203
                 break;
a04203
+            }
a04203
         }
a04203
+
a04203
         if (part) {
a04203
             PyErr_SetString(PartitionException, "Attempting to remove an extended partition that still contains logical partitions");
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
 
a04203
     ret = ped_disk_remove_partition(disk, out_part);
a04203
+
a04203
     if (ret == 0) {
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(PartitionException, partedExnMessage);
a04203
-        }
a04203
-        else
a04203
+            }
a04203
+        } else {
a04203
             PyErr_Format(PartitionException, "Could not remove partition %s%d", out_part->disk->dev->path, out_part->num);
a04203
+        }
a04203
 
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     in_part->_owned = 0;
a04203
@@ -1591,25 +1602,24 @@ PyObject *py_ped_disk_delete_all(PyObjec
a04203
     int ret = 0;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         ret = ped_disk_delete_all(disk);
a04203
+
a04203
         if (ret == 0) {
a04203
             if (partedExnRaised) {
a04203
                 partedExnRaised = 0;
a04203
 
a04203
-                if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                    !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+                if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                     PyErr_SetString(PartitionException, partedExnMessage);
a04203
-            }
a04203
-            else
a04203
+                }
a04203
+            } else {
a04203
                 PyErr_Format(PartitionException, "Could not remove all partitions on %s", disk->dev->path);
a04203
+            }
a04203
 
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
-    }
a04203
 
a04203
     if (ret) {
a04203
         Py_RETURN_TRUE;
a04203
@@ -1627,57 +1637,58 @@ PyObject *py_ped_disk_set_partition_geom
a04203
     PedSector start, end;
a04203
     int ret = 0;
a04203
 
a04203
-    if (!PyArg_ParseTuple(args, "O!OLL", &_ped_Partition_Type_obj, &in_part,
a04203
-                          &in_constraint, &start, &end)) {
a04203
-        return NULL;
a04203
+    if (!PyArg_ParseTuple(args, "O!OLL", &_ped_Partition_Type_obj, &in_part, &in_constraint, &start, &end)) {
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
-    if (in_constraint != Py_None && !PyObject_IsInstance(in_constraint,
a04203
-                                      (PyObject *)&_ped_Constraint_Type_obj)) {
a04203
+    if (in_constraint != Py_None && !PyObject_IsInstance(in_constraint, (PyObject *)&_ped_Constraint_Type_obj)) {
a04203
         PyErr_SetString(PyExc_ValueError, "invalid constraint type");
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     out_part = _ped_Partition2PedPartition(in_part);
a04203
+
a04203
     if (out_part == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (out_part->disk != disk) {
a04203
         PyErr_SetString(PartitionException, "partition.disk does not match disk");
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (in_constraint != Py_None) {
a04203
         out_constraint = _ped_Constraint2PedConstraint(in_constraint);
a04203
+
a04203
         if (out_constraint == NULL) {
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
 
a04203
-    ret = ped_disk_set_partition_geom(disk, out_part, out_constraint,
a04203
-                                      start, end);
a04203
+    ret = ped_disk_set_partition_geom(disk, out_part, out_constraint, start, end);
a04203
 
a04203
-    if (out_constraint)
a04203
+    if (out_constraint) {
a04203
         ped_constraint_destroy(out_constraint);
a04203
+    }
a04203
 
a04203
     if (ret == 0) {
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(PartitionException, partedExnMessage);
a04203
-        }
a04203
-        else
a04203
+            }
a04203
+        } else {
a04203
             PyErr_Format(PartitionException, "Could not set geometry on %s%d", disk->dev->path, out_part->num);
a04203
+        }
a04203
 
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     *((_ped_Geometry *)in_part->geom)->ped_geometry = out_part->geom;
a04203
@@ -1697,50 +1708,53 @@ PyObject *py_ped_disk_maximize_partition
a04203
     PedConstraint *out_constraint = NULL;
a04203
     int ret = 0;
a04203
 
a04203
-    if (!PyArg_ParseTuple(args, "O!|O!", &_ped_Partition_Type_obj, &in_part,
a04203
-                          &_ped_Constraint_Type_obj, &in_constraint)) {
a04203
-        return NULL;
a04203
+    if (!PyArg_ParseTuple(args, "O!|O!", &_ped_Partition_Type_obj, &in_part, &_ped_Constraint_Type_obj, &in_constraint)) {
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     out_part = _ped_Partition2PedPartition(in_part);
a04203
+
a04203
     if (out_part == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (out_part->disk != disk) {
a04203
         PyErr_SetString(PartitionException, "partition.disk does not match disk");
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (in_constraint) {
a04203
         out_constraint = _ped_Constraint2PedConstraint(in_constraint);
a04203
+
a04203
         if (out_constraint == NULL) {
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
 
a04203
     ret = ped_disk_maximize_partition(disk, out_part, out_constraint);
a04203
 
a04203
-    if (out_constraint)
a04203
+    if (out_constraint) {
a04203
         ped_constraint_destroy(out_constraint);
a04203
+    }
a04203
 
a04203
     if (ret == 0) {
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(PartitionException, partedExnMessage);
a04203
-        }
a04203
-        else
a04203
+            }
a04203
+        } else {
a04203
             PyErr_Format(PartitionException, "Could not maximize partition size for %s%d", disk->dev->path, out_part->num);
a04203
+        }
a04203
 
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     *((_ped_Geometry *)in_part->geom)->ped_geometry = out_part->geom;
a04203
@@ -1761,55 +1775,59 @@ PyObject *py_ped_disk_get_max_partition_
a04203
     PedGeometry *pass_geom = NULL;
a04203
     _ped_Geometry *ret = NULL;
a04203
 
a04203
-    if (!PyArg_ParseTuple(args, "O!|O!", &_ped_Partition_Type_obj, &in_part,
a04203
-                          &_ped_Constraint_Type_obj, &in_constraint)) {
a04203
-        return NULL;
a04203
+    if (!PyArg_ParseTuple(args, "O!|O!", &_ped_Partition_Type_obj, &in_part, &_ped_Constraint_Type_obj, &in_constraint)) {
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     out_part = _ped_Partition2PedPartition(in_part);
a04203
+
a04203
     if (out_part == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (out_part->disk != disk) {
a04203
         PyErr_SetString(PartitionException, "partition.disk does not match disk");
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (in_constraint) {
a04203
         out_constraint = _ped_Constraint2PedConstraint(in_constraint);
a04203
+
a04203
         if (out_constraint == NULL) {
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
 
a04203
     pass_geom = ped_disk_get_max_partition_geometry(disk, out_part,
a04203
                                                     out_constraint);
a04203
-    if (out_constraint)
a04203
+    if (out_constraint) {
a04203
         ped_constraint_destroy(out_constraint);
a04203
+    }
a04203
 
a04203
     if (pass_geom == NULL) {
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(PartitionException, partedExnMessage);
a04203
-        }
a04203
-        else
a04203
+            }
a04203
+        } else {
a04203
             PyErr_Format(PartitionException, "Could not get maximum partition size for %s%d", disk->dev->path, out_part->num);
a04203
+        }
a04203
 
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret = PedGeometry2_ped_Geometry(pass_geom);
a04203
+
a04203
     if (ret == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     return (PyObject *) ret;
a04203
@@ -1820,25 +1838,24 @@ PyObject *py_ped_disk_minimize_extended_
a04203
     int ret = 0;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         ret = ped_disk_minimize_extended_partition(disk);
a04203
+
a04203
         if (ret == 0) {
a04203
             if (partedExnRaised) {
a04203
                 partedExnRaised = 0;
a04203
 
a04203
-                if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                    !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+                if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                     PyErr_SetString(PartitionException, partedExnMessage);
a04203
-            }
a04203
-            else
a04203
+                }
a04203
+            } else {
a04203
                 PyErr_Format(PartitionException, "Could not shrink extended partition on %s", disk->dev->path);
a04203
+            }
a04203
 
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
-    else {
a04203
-        return NULL;
a04203
-    }
a04203
 
a04203
     if (ret) {
a04203
         Py_RETURN_TRUE;
a04203
@@ -1855,38 +1872,41 @@ PyObject *py_ped_disk_next_partition(PyO
a04203
     _ped_Partition *ret = NULL;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "|O!", &_ped_Partition_Type_obj, &in_part)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if (in_part) {
a04203
         out_part = _ped_Partition2PedPartition(in_part);
a04203
+
a04203
         if (out_part == NULL) {
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
 
a04203
         if (out_part->disk != disk) {
a04203
             PyErr_SetString(PartitionException, "partition.disk does not match disk");
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
     }
a04203
 
a04203
     pass_part = ped_disk_next_partition(disk, out_part);
a04203
+
a04203
     if (pass_part == NULL) {
a04203
         Py_INCREF(Py_None);
a04203
         return Py_None;
a04203
     }
a04203
 
a04203
     ret = PedPartition2_ped_Partition(pass_part, (_ped_Disk *)s);
a04203
-    if (ret == NULL) {
a04203
-        return NULL;
a04203
+
a04203
+    if (ret != NULL) {
a04203
+        ret->_owned = 1;
a04203
     }
a04203
 
a04203
-    ret->_owned = 1;
a04203
     return (PyObject *) ret;
a04203
 }
a04203
 
a04203
@@ -1897,27 +1917,28 @@ PyObject *py_ped_disk_get_partition(PyOb
a04203
     _ped_Partition *ret = NULL;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "i", &num)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         pass_part = ped_disk_get_partition(disk, num);
a04203
+
a04203
         if (pass_part == NULL) {
a04203
             PyErr_SetString(PartitionException, "Partition does not exist");
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
 
a04203
         ret = PedPartition2_ped_Partition(pass_part, (_ped_Disk *)s);
a04203
+
a04203
         if (ret == NULL) {
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
-    }
a04203
-    else {
a04203
-        return NULL;
a04203
+
a04203
+        ret->_owned = 1;
a04203
     }
a04203
 
a04203
-    ret->_owned = 1;
a04203
     return (PyObject *) ret;
a04203
 }
a04203
 
a04203
@@ -1928,23 +1949,26 @@ PyObject *py_ped_disk_get_partition_by_s
a04203
     _ped_Partition *ret = NULL;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "L", &sector)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     pass_part = ped_disk_get_partition_by_sector(disk, sector);
a04203
+
a04203
     if (pass_part == NULL) {
a04203
         PyErr_SetString(PartitionException, "Partition does not exist");
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret = PedPartition2_ped_Partition(pass_part, (_ped_Disk *)s);
a04203
+
a04203
     if (ret == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret->_owned = 1;
a04203
@@ -1957,23 +1981,24 @@ PyObject *py_ped_disk_extended_partition
a04203
     _ped_Partition *ret = NULL;
a04203
 
a04203
     disk = _ped_Disk2PedDisk(s);
a04203
+
a04203
     if (disk) {
a04203
         pass_part = ped_disk_extended_partition(disk);
a04203
+
a04203
         if (pass_part == NULL) {
a04203
             PyErr_SetString(PartitionException, "Extended partition does not exist");
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
 
a04203
         ret = PedPartition2_ped_Partition(pass_part, (_ped_Disk *)s);
a04203
+
a04203
         if (ret == NULL) {
a04203
-            return NULL;
a04203
+            return (PyObject *) NULL;
a04203
         }
a04203
-    }
a04203
-    else {
a04203
-        return NULL;
a04203
+
a04203
+        ret->_owned = 1;
a04203
     }
a04203
 
a04203
-    ret->_owned = 1;
a04203
     return (PyObject *) ret;
a04203
 }
a04203
 
a04203
@@ -1985,26 +2010,25 @@ PyObject *py_ped_disk_new_fresh(PyObject
a04203
     PedDisk *disk = NULL;
a04203
     _ped_Disk *ret = NULL;
a04203
 
a04203
-    if (!PyArg_ParseTuple(args, "O!O!", &_ped_Device_Type_obj, &in_device,
a04203
-                                        &_ped_DiskType_Type_obj, &in_type)) {
a04203
-        return NULL;
a04203
+    if (!PyArg_ParseTuple(args, "O!O!", &_ped_Device_Type_obj, &in_device, &_ped_DiskType_Type_obj, &in_type)) {
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if ((device = _ped_Device2PedDevice((PyObject *) in_device)) == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if ((type = _ped_DiskType2PedDiskType((PyObject *) in_type)) == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if ((disk = ped_disk_new_fresh(device, type)) == NULL) {
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(DiskException, partedExnMessage);
a04203
+            }
a04203
         } else {
a04203
             if (disk->dev == NULL) {
a04203
                 PyErr_Format(DiskException, "Could not create new disk label");
a04203
@@ -2013,7 +2037,7 @@ PyObject *py_ped_disk_new_fresh(PyObject
a04203
             }
a04203
         }
a04203
 
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret = PedDisk2_ped_Disk(disk);
a04203
@@ -2027,20 +2051,20 @@ PyObject *py_ped_disk_new(PyObject *s, P
a04203
     _ped_Disk *ret = NULL;
a04203
 
a04203
     if (!PyArg_ParseTuple(args, "O!", &_ped_Device_Type_obj, &in_device)) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if ((device = _ped_Device2PedDevice((PyObject *) in_device)) == NULL) {
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     if ((disk = ped_disk_new(device)) == NULL) {
a04203
         if (partedExnRaised) {
a04203
             partedExnRaised = 0;
a04203
 
a04203
-            if (!PyErr_ExceptionMatches(PartedException) &&
a04203
-                !PyErr_ExceptionMatches(PyExc_NotImplementedError))
a04203
+            if (!PyErr_ExceptionMatches(PartedException) && !PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
a04203
                 PyErr_SetString(DiskException, partedExnMessage);
a04203
+            }
a04203
         } else {
a04203
             if (disk->dev == NULL) {
a04203
                 PyErr_Format(DiskException, "Could not create new disk label");
a04203
@@ -2049,7 +2073,7 @@ PyObject *py_ped_disk_new(PyObject *s, P
a04203
             }
a04203
         }
a04203
 
a04203
-        return NULL;
a04203
+        return (PyObject *) NULL;
a04203
     }
a04203
 
a04203
     ret = PedDisk2_ped_Disk(disk);
a04203
diff -up pyparted-3.11.7/src/pytimer.c.orig pyparted-3.11.7/src/pytimer.c
a04203
--- pyparted-3.11.7/src/pytimer.c.orig	2019-04-23 14:24:26.657517400 -0400
a04203
+++ pyparted-3.11.7/src/pytimer.c	2021-07-09 15:09:17.827164706 -0400
a04203
@@ -104,33 +104,9 @@ int _ped_Timer_clear(_ped_Timer *self) {
a04203
 }
a04203
 
a04203
 int _ped_Timer_init(_ped_Timer *self, PyObject *args, PyObject *kwds) {
a04203
-    static char *kwlist[] = {"frac", "start", "now", "predicted_end",
a04203
-                             "state_name", NULL};
a04203
-
a04203
-    self->state_name = NULL;
a04203
-
a04203
     /* XXX: timers aren't really done yet in pyparted */
a04203
     PyErr_SetString(PyExc_NotImplementedError, NULL);
a04203
     return -1;
a04203
-
a04203
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|fdddz", kwlist,
a04203
-                                     &self->frac, &self->start, &self->now,
a04203
-                                     &self->predicted_end, &self->state_name)) {
a04203
-        return -1;
a04203
-    }
a04203
-
a04203
-     /* self->state_name now points to the internal buffer of a PyUnicode object,
a04203
-      * which may be freed when its refcount drops to zero, so strdup it.
a04203
-      */
a04203
-     if (self->state_name) {
a04203
-         self->state_name = strdup(self->state_name);
a04203
-         if (!self->state_name) {
a04203
-             PyErr_NoMemory();
a04203
-             return -3;
a04203
-         }
a04203
-     }
a04203
-
a04203
-    return 0;
a04203
 }
a04203
 
a04203
 PyObject *_ped_Timer_get(_ped_Timer *self, void *closure) {