All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Jan Beulich <jbeulich@novell.com>
Cc: Jim Fehlig <JFEHLIG@novell.com>,
	Xen Development Mailing List <xen-devel@lists.xensource.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: Re: [patch] fix python 2.6 warnings
Date: Tue, 10 Mar 2009 16:52:57 +0100	[thread overview]
Message-ID: <49B68CD9.2080201@redhat.com> (raw)
In-Reply-To: <49B68AAE.76E4.0078.0@novell.com>

[-- Attachment #1: Type: text/plain, Size: 601 bytes --]

Jan Beulich wrote:
>>>> Gerd Hoffmann <kraxel@redhat.com> 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


[-- Attachment #2: fix.deprecated --]
[-- Type: text/plain, Size: 1563 bytes --]

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
             }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

  reply	other threads:[~2009-03-10 15:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-10 11:28 [patch] fix python 2.6 warnings Gerd Hoffmann
2009-03-10 12:16 ` Gerd Hoffmann
2009-03-10 12:18 ` Ian Jackson
2009-03-10 13:44   ` Gerd Hoffmann
2009-03-10 14:20     ` John Levon
2009-03-10 14:43     ` Jan Beulich
2009-03-10 15:52       ` Gerd Hoffmann [this message]
2009-03-10 16:49       ` Marc - A. Dahlhaus
2009-03-10 17:49     ` Ian Jackson
2009-03-10 12:28 ` M A Young

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49B68CD9.2080201@redhat.com \
    --to=kraxel@redhat.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JFEHLIG@novell.com \
    --cc=jbeulich@novell.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.