virt-manager/056-delete-Fix-ambiguity-that-confused-pylint.patch

71 lines
2.6 KiB
Diff

Subject: delete: Fix ambiguity that confused pylint
From: Cole Robinson crobinso@redhat.com Sun Sep 24 16:13:00 2023 -0400
Date: Sun Sep 24 16:31:58 2023 -0400:
Git: ab0a318a46b1ab5c7827fc805b8c4e21635d66ab
virtManager/delete.py:219:11: E0601: Using variable 'error' before assignment (used-before-assignment)
Signed-off-by: Cole Robinson <crobinso@redhat.com>
diff --git a/virtManager/delete.py b/virtManager/delete.py
index f050534b..2195a5d9 100644
--- a/virtManager/delete.py
+++ b/virtManager/delete.py
@@ -179,8 +179,9 @@ class _vmmDeleteBase(vmmGObjectUI):
self._set_vm(None)
def _async_delete(self, asyncjob, vm, paths):
- details = ""
+ errdata = None
storage_errors = []
+
try:
self._destroy_vm(vm)
@@ -191,33 +192,32 @@ class _vmmDeleteBase(vmmGObjectUI):
self._delete_vm(vm)
vm.conn.schedule_priority_tick(pollvm=True)
except Exception as e: # pragma: no cover
- error = _("Error deleting virtual machine '%(vm)s': %(error)s") % {
- "vm": vm.get_name(),
- "error": str(e),
- }
- details = "".join(traceback.format_exc())
+ errdata = (
+ (_("Error deleting virtual machine '%(vm)s': %(error)s") %
+ {"vm": vm.get_name(), "error": str(e)}),
+ "".join(traceback.format_exc()))
+
+ if not storage_errors and not errdata:
+ return
storage_errstr = ""
for errinfo in storage_errors:
storage_errstr += "%s\n%s\n" % (errinfo[0], errinfo[1])
- if not storage_errstr and not details:
- return
-
# We had extra storage errors. If there was another error message,
# errors to it. Otherwise, build the main error around them.
- if details: # pragma: no cover
+ if errdata: # pragma: no cover
+ error, details = errdata
details += "\n\n"
details += _("Additionally, there were errors removing"
- " certain storage devices: \n")
+ " certain storage devices: \n")
details += storage_errstr
else:
error = _("Errors encountered while removing certain "
- "storage devices.")
+ "storage devices.")
details = storage_errstr
- if error:
- asyncjob.set_error(error, details)
+ asyncjob.set_error(error, details)
def _async_delete_paths(self, paths, conn, meter):
storage_errors = []