[libvirt] [libvirt-python 2/3] generator: Support exceptions in Python 2 and 3

Doug Goldstein cardoe at cardoe.com
Wed Dec 4 20:34:07 UTC 2013


Use a syntax for exception handling that works in both Python 2 and
Python 3
---
 generator.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/generator.py b/generator.py
index 0717624..009d3e1 100755
--- a/generator.py
+++ b/generator.py
@@ -818,7 +818,8 @@ def buildStubs(module, api_xml):
         (parser, target)  = getparser()
         parser.feed(data)
         parser.close()
-    except IOError, msg:
+    except IOError:
+        msg = sys.exc_info()[1]
         print(file, ":", msg)
         sys.exit(1)
 
@@ -837,7 +838,8 @@ def buildStubs(module, api_xml):
         (parser, target)  = getparser()
         parser.feed(data)
         parser.close()
-    except IOError, msg:
+    except IOError:
+        msg = sys.exc_info()[1]
         print(file, ":", msg)
 
     if not quiet:
-- 
1.8.3.2




More information about the libvir-list mailing list