From: Vratislav Podzimek vpodzime@redhat.com
If there's a variable 'e' and then 'except Exception as e' appears and really catches an exception, the variable 'e' no longer exists after the 'except' block is left. Let's just use a better name for the variable.
Also 'raise' is a statement not a function. --- blivet/devicefactory.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/blivet/devicefactory.py b/blivet/devicefactory.py index 0c795be..6689380 100644 --- a/blivet/devicefactory.py +++ b/blivet/devicefactory.py @@ -639,18 +639,19 @@ def _create_device(self): raise
self.storage.createDevice(device) - e = None + error = None try: self._post_create() except (StorageError, blockdev.BlockDevError) as e: log.error("device post-create method failed: %s", e) + error = e else: if not device.size: - e = StorageError("failed to create device") + error = StorageError("failed to create device")
- if e: + if error: self.storage.destroyDevice(device) - raise StorageError(e) + raise StorageError(error)
ret = device if self.encrypted: @@ -825,7 +826,7 @@ def configure(self): if not isinstance(e, (StorageError, OverflowError)): e = DeviceFactoryError(str(e))
- raise(e) + raise e
def _configure(self): self._set_container()