[blivet:master] Add likely to be raised exceptions to catch block (#1150174)

mulhern amulhern at redhat.com
Tue Oct 7 18:26:42 UTC 2014


Resolves: fed#1150174

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/devices/storage.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index 28a9d4f..6fb8a63 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -297,7 +297,12 @@ class StorageDevice(Device):
         try:
             udev_device = pyudev.Device.from_device_file(udev.global_udev,
                                                          self.path)
-        except pyudev.DeviceNotFoundError as e:
+
+        # from_device_file() does not process exceptions but just propagates
+        # ValueErrors and EnvironmentErrors that may be raised. So catch
+        # those errors, but also catch DeviceNotFoundError, which is the
+        # appropriate exception and which it may raise in future.
+        except (pyudev.DeviceNotFoundError, EnvironmentError, ValueError) as e:
             log.error("failed to update sysfs path for %s: %s", self.name, e)
             self.sysfsPath = ''
         else:
-- 
1.9.3



More information about the anaconda-patches mailing list