WARNING - OLD ARCHIVES

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/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [patch] fix python 2.6 warnings

To: Jan Beulich <jbeulich@xxxxxxxxxx>
Subject: Re: [Xen-devel] [patch] fix python 2.6 warnings
From: "Marc - A. Dahlhaus" <mad@xxxxxx>
Date: Tue, 10 Mar 2009 17:49:49 +0100
Cc: Jim Fehlig <JFEHLIG@xxxxxxxxxx>, Xen Development Mailing List <xen-devel@xxxxxxxxxxxxxxxxxxx>, Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>, Gerd Hoffmann <kraxel@xxxxxxxxxx>
Delivery-date: Tue, 10 Mar 2009 09:50:13 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <49B68AAE.76E4.0078.0@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>
References: <49B64EC3.4070303@xxxxxxxxxx> <18870.23173.605053.102901@xxxxxxxxxxxxxxxxxxxxxxxx> <49B66EB3.5010405@xxxxxxxxxx> <49B68AAE.76E4.0078.0@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)
Jan Beulich schrieb:
Gerd Hoffmann <kraxel@xxxxxxxxxx> 10.03.09 14:44 >>>
Which makes me think at least the hashlib one needs a more sophisticated
approach so it keeps working on pre-2.5 versions ...

Something like this (I had hoped this would have been submitted long ago,
but apparently it wasn't even attempted).

Jan

--- xen-3.3.1-testing.orig/tools/python/xen/util/acmpolicy.py
+++ xen-3.3.1-testing/tools/python/xen/util/acmpolicy.py
@@ -17,7 +17,10 @@
 #============================================================================
import os
-import sha
+try:
+    import hashlib # python v2.6 or newer
+except ImportError:
+    import sha # python v2.5 or older
 import stat
 import array
 import struct


hello,

this might work better

-import sha
+try:
+    import sha1 from hashlib # python v2.5 or newer
+except ImportError:
+    import sha as sha1 # pre python v2.5


and call it with: sha1( foo )

Marc

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel