From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gerd Hoffmann Subject: Re: [patch] fix python 2.6 warnings Date: Tue, 10 Mar 2009 16:52:57 +0100 Message-ID: <49B68CD9.2080201@redhat.com> References: <49B64EC3.4070303@redhat.com> <18870.23173.605053.102901@mariner.uk.xensource.com> <49B66EB3.5010405@redhat.com> <49B68AAE.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080805040304000801060009" Return-path: In-Reply-To: <49B68AAE.76E4.0078.0@novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich Cc: Jim Fehlig , Xen Development Mailing List , Ian Jackson List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------080805040304000801060009 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Jan Beulich wrote: >>>> Gerd Hoffmann 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). > -import sha > +try: > + import hashlib # python v2.6 or newer > +except ImportError: > + import sha # python v2.5 or older Well, due to the renaming (sha.sha -> hashlib.sha1) it isn't *that* easy. Patch below could work. WARNING: untested. cheers, Gerd --------------080805040304000801060009 Content-Type: text/plain; name="fix.deprecated" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fix.deprecated" diff -up xen-3.3.1/tools/python/xen/util/acmpolicy.py.deprecated xen-3.3.1/tools/python/xen/util/acmpolicy.py --- xen-3.3.1/tools/python/xen/util/acmpolicy.py.deprecated 2009-03-09 17:22:39.000000000 +0100 +++ xen-3.3.1/tools/python/xen/util/acmpolicy.py 2009-03-10 16:48:14.000000000 +0100 @@ -17,7 +17,10 @@ #============================================================================ import os -import sha +try: + from hashlib import sha1 +except ImportError: + from sha import sha as sha1 import stat import array import struct @@ -1103,7 +1106,7 @@ class ACMPolicy(XSPolicy): def hash(self): """ Calculate a SAH1 hash of the XML policy """ - return sha.sha(self.toxml()) + return sha1(self.toxml()) def save(self): ### Save the XML policy into a file ### diff -up xen-3.3.1/tools/python/xen/xend/XendAPI.py.deprecated xen-3.3.1/tools/python/xen/xend/XendAPI.py --- xen-3.3.1/tools/python/xen/xend/XendAPI.py.deprecated 2009-03-10 11:16:47.000000000 +0100 +++ xen-3.3.1/tools/python/xen/xend/XendAPI.py 2009-03-10 13:13:33.000000000 +0100 @@ -18,7 +18,6 @@ import inspect import os import Queue -import sets import string import sys import traceback @@ -116,7 +115,7 @@ event_registrations = {} def event_register(session, reg_classes): if session not in event_registrations: event_registrations[session] = { - 'classes' : sets.Set(), + 'classes' : set(), 'queue' : Queue.Queue(EVENT_QUEUE_LENGTH), 'next-id' : 1 } --------------080805040304000801060009 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------080805040304000801060009--