[virt-manager][PATCH] py3: store exception variables for use outside except

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In python3 exceptions aren't defined outside the except block. Leading
to 'UnboundLocalError: local variable 'e' referenced before assignment'
errors.

To work around this, store the local variable into one that will have a
longer life.
---
 virtManager/connection.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/virtManager/connection.py b/virtManager/connection.py
index c98fff3d..f9da6677 100644
--- a/virtManager/connection.py
+++ b/virtManager/connection.py
@@ -1439,7 +1439,8 @@ class vmmConnection(vmmGObject):
             self._tick(*args, **kwargs)
         except KeyboardInterrupt:
             raise
-        except Exception as e:
+        except Exception as err:
+            e = err
             pass
 
         if e is None:
-- 
2.15.1

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux