[libvirt] [PATCH python 15/15] override: Fix exception catching syntax

Daniel P. Berrange berrange at redhat.com
Tue Dec 3 16:36:51 UTC 2013


From: "Daniel P. Berrange" <berrange at redhat.com>

In Python3 you cannot use 'except Foo, e' you must use
'except Foo as e' instead, or just 'except Foo' if the
variable isn't required.

Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 libvirt-override-virStream.py | 6 +++---
 libvirt-override.py           | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libvirt-override-virStream.py b/libvirt-override-virStream.py
index 53000da..cf54a01 100644
--- a/libvirt-override-virStream.py
+++ b/libvirt-override-virStream.py
@@ -50,12 +50,12 @@
                 ret = handler(self, got, opaque)
                 if type(ret) is int and ret < 0:
                     raise RuntimeError("recvAll handler returned %d" % ret)
-            except Exception, e:
+            except:
                 try:
                     self.abort()
                 except:
                     pass
-                raise e
+                raise
 
     def sendAll(self, handler, opaque):
         """
@@ -79,7 +79,7 @@
                     self.abort()
                 except:
                     pass
-                raise e
+                raise
 
             if got == "":
                 break
diff --git a/libvirt-override.py b/libvirt-override.py
index 87996f8..e356a10 100644
--- a/libvirt-override.py
+++ b/libvirt-override.py
@@ -5,10 +5,10 @@
 # On cygwin, the DLL is called cygvirtmod.dll
 try:
     import libvirtmod
-except ImportError, lib_e:
+except ImportError as lib_e:
     try:
         import cygvirtmod as libvirtmod
-    except ImportError, cyg_e:
+    except ImportError as cyg_e:
         if str(cyg_e).count("No module named"):
             raise lib_e
 
-- 
1.8.3.1




More information about the libvir-list mailing list