This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


[Xen-devel] Re: [Pkg-xen-devel] using xen tools with python2.6

To: Matthias Klose <doko@xxxxxxxxxx>
Subject: [Xen-devel] Re: [Pkg-xen-devel] using xen tools with python2.6
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Mon, 13 Sep 2010 09:38:47 +0100
Cc: xen@xxxxxxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 13 Sep 2010 01:39:25 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4C8CE2BD.2000404@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <4C8CE2BD.2000404@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Sun, 2010-09-12 at 16:25 +0200, Matthias Klose wrote:
> there are at least some syntax errors when trying to use the xen utils with 
> python2.6.  The attached patch changes these string exception into 
> ValueError's.

Thanks Matthias.

>   - tools/python/xen/util/bugtool.py (getBugTitle)
>   - tools/python/xen/xend (class XendBase): not catched
>   - tools/python/xen/xm/xenapi_create.py (sxp2xmlconvert_sxp_to_xml):
>     the method already raises a ValueError for similiar condition.
>   - tools/python/xen/xm/main.py (xm_network_attach): not catched.
> For all but maybe the first one, the replacement of the string exceptions 
> into 
> ValueError's seems to be safe.

Why is the first one potentially unsafe?

What do you mean by "not catched" here? Just that nothing catches the

Please could you provide a Signed-off-by line for upstream?


Description: Replace python string exceptions with ValueError exceptions
Author: Matthias Klose <doko@xxxxxxxxxx>
Bug-Debian: http://bugs.debian.org/585372

--- xen-4.0.1.orig/tools/python/xen/util/bugtool.py
+++ xen-4.0.1/tools/python/xen/util/bugtool.py
@@ -139,7 +139,7 @@ def getBugTitle(bug):
-    raise "Could not find title of bug %d!" % bug
+    raise ValueError("Could not find title of bug %d!" % bug)
 def send(bug, conn, fd, filename, username, password):
--- xen-4.0.1.orig/tools/python/xen/xend/XendBase.py
+++ xen-4.0.1/tools/python/xen/xend/XendBase.py
@@ -114,7 +114,7 @@ class XendBase:
             # In OSS, ref == uuid
             return uuid
-            raise "Big Error.. TODO!"
+            raise ValueError("Big Error.. TODO!")
     def get_all_records(cls):
         return dict([(inst.get_uuid(), inst.get_record())
--- xen-4.0.1.orig/tools/python/xen/xm/xenapi_create.py
+++ xen-4.0.1/tools/python/xen/xm/xenapi_create.py
@@ -702,7 +702,7 @@ class sxp2xml:
                 vm.attributes['security_label'] = \
             except Exception, e:
-                raise "Invalid security data format: %s" % str(sec_data)
+                raise ValueError("Invalid security data format: %s" % 
         # Make the name tag
--- xen-4.0.1.orig/tools/python/xen/xm/main.py
+++ xen-4.0.1/tools/python/xen/xm/main.py
@@ -2616,7 +2616,7 @@ def xm_network_attach(args):
                              for ref, record in server.xenapi.network
             if bridge not in networks.keys():
-                raise "Unknown bridge name!"
+                raise ValueError("Unknown bridge name!")
             return networks[bridge]
         vif_conv = {

Xen-devel mailing list