* [patch] fix python 2.6 warnings
@ 2009-03-10 11:28 Gerd Hoffmann
2009-03-10 12:16 ` Gerd Hoffmann
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2009-03-10 11:28 UTC (permalink / raw)
To: Xen Development Mailing List
[-- Attachment #1: Type: text/plain, Size: 92 bytes --]
Hi,
Attached patch fixes a few python warnings about deprecated modules.
cheers,
Gerd
[-- Attachment #2: fix.deprecated --]
[-- Type: text/plain, Size: 1496 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-09 17:23:09.000000000 +0100
@@ -17,7 +17,7 @@
#============================================================================
import os
-import sha
+import hashlib
import stat
import array
import struct
@@ -1103,7 +1103,7 @@ class ACMPolicy(XSPolicy):
def hash(self):
""" Calculate a SAH1 hash of the XML policy """
- return sha.sha(self.toxml())
+ return hashlib.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 11:17:34.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(),
+ 'slasses' : 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
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch] fix python 2.6 warnings
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 12:28 ` M A Young
2 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2009-03-10 12:16 UTC (permalink / raw)
To: Xen Development Mailing List
[-- Attachment #1: Type: text/plain, Size: 172 bytes --]
Gerd Hoffmann wrote:
> Hi,
>
> Attached patch fixes a few python warnings about deprecated modules.
Oops, that one had a tyops, fixed version attached.
cheers,
Gerd
[-- Attachment #2: fix.deprecated --]
[-- Type: text/plain, Size: 1496 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-09 17:23:09.000000000 +0100
@@ -17,7 +17,7 @@
#============================================================================
import os
-import sha
+import hashlib
import stat
import array
import struct
@@ -1103,7 +1103,7 @@ class ACMPolicy(XSPolicy):
def hash(self):
""" Calculate a SAH1 hash of the XML policy """
- return sha.sha(self.toxml())
+ return hashlib.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
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch] fix python 2.6 warnings
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 12:28 ` M A Young
2 siblings, 1 reply; 10+ messages in thread
From: Ian Jackson @ 2009-03-10 12:18 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: Xen Development Mailing List
Gerd Hoffmann writes ("[Xen-devel] [patch] fix python 2.6 warnings"):
> Attached patch fixes a few python warnings about deprecated modules.
Can you please confirm in which Python version the new modules were
introduced ? Some people (including our automatic test systems!) are
using very old versions of python and it would be nice if that kept
working.
Ian.
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch] fix python 2.6 warnings
2009-03-10 12:18 ` Ian Jackson
@ 2009-03-10 13:44 ` Gerd Hoffmann
2009-03-10 14:20 ` John Levon
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2009-03-10 13:44 UTC (permalink / raw)
To: Ian Jackson; +Cc: Xen Development Mailing List
Ian Jackson wrote:
> Gerd Hoffmann writes ("[Xen-devel] [patch] fix python 2.6 warnings"):
>> Attached patch fixes a few python warnings about deprecated modules.
>
> Can you please confirm in which Python version the new modules were
> introduced ? Some people (including our automatic test systems!) are
> using very old versions of python and it would be nice if that kept
> working.
set type (obsoletes sets module) was added in 2.4
hashlib (obsoletes sha module) was added in 2.5
For reference: RHEL-5 ships with python 2.4.
Which makes me think at least the hashlib one needs a more sophisticated
approach so it keeps working on pre-2.5 versions ...
cheers,
Gerd
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch] fix python 2.6 warnings
2009-03-10 13:44 ` Gerd Hoffmann
@ 2009-03-10 14:20 ` John Levon
2009-03-10 14:43 ` Jan Beulich
2009-03-10 17:49 ` Ian Jackson
2 siblings, 0 replies; 10+ messages in thread
From: John Levon @ 2009-03-10 14:20 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: Xen Development Mailing List, Ian Jackson
On Tue, Mar 10, 2009 at 02:44:19PM +0100, Gerd Hoffmann wrote:
> > Can you please confirm in which Python version the new modules were
> > introduced ? Some people (including our automatic test systems!) are
> > using very old versions of python and it would be nice if that kept
> > working.
>
> set type (obsoletes sets module) was added in 2.4
> hashlib (obsoletes sha module) was added in 2.5
We're using 2.4 too (we have 2.5, and 2.6, but haven't yet done the work
to move versions).
regards
john
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] fix python 2.6 warnings
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
2009-03-10 16:49 ` Marc - A. Dahlhaus
2009-03-10 17:49 ` Ian Jackson
2 siblings, 2 replies; 10+ messages in thread
From: Jan Beulich @ 2009-03-10 14:43 UTC (permalink / raw)
To: Ian Jackson, Gerd Hoffmann; +Cc: Jim Fehlig, Xen Development Mailing List
>>> 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).
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] fix python 2.6 warnings
2009-03-10 14:43 ` Jan Beulich
@ 2009-03-10 15:52 ` Gerd Hoffmann
2009-03-10 16:49 ` Marc - A. Dahlhaus
1 sibling, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2009-03-10 15:52 UTC (permalink / raw)
To: Jan Beulich; +Cc: Jim Fehlig, Xen Development Mailing List, Ian Jackson
[-- 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
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch] fix python 2.6 warnings
2009-03-10 14:43 ` Jan Beulich
2009-03-10 15:52 ` Gerd Hoffmann
@ 2009-03-10 16:49 ` Marc - A. Dahlhaus
1 sibling, 0 replies; 10+ messages in thread
From: Marc - A. Dahlhaus @ 2009-03-10 16:49 UTC (permalink / raw)
To: Jan Beulich
Cc: Jim Fehlig, Xen Development Mailing List, Ian Jackson,
Gerd Hoffmann
Jan Beulich schrieb:
>>>> 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).
>
> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] fix python 2.6 warnings
2009-03-10 13:44 ` Gerd Hoffmann
2009-03-10 14:20 ` John Levon
2009-03-10 14:43 ` Jan Beulich
@ 2009-03-10 17:49 ` Ian Jackson
2 siblings, 0 replies; 10+ messages in thread
From: Ian Jackson @ 2009-03-10 17:49 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: Xen Development Mailing List
Gerd Hoffmann writes ("Re: [Xen-devel] [patch] fix python 2.6 warnings"):
> set type (obsoletes sets module) was added in 2.4
> hashlib (obsoletes sha module) was added in 2.5
>
> For reference: RHEL-5 ships with python 2.4.
The automated test systems which manage propagation from staging to
xen-unstable are running python 2.3.
Ian.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] fix python 2.6 warnings
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 12:28 ` M A Young
2 siblings, 0 replies; 10+ messages in thread
From: M A Young @ 2009-03-10 12:28 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: Xen Development Mailing List
On Tue, 10 Mar 2009, Gerd Hoffmann wrote:
> Attached patch fixes a few python warnings about deprecated modules.
Do you mean 'slasses'? My knowledge of python isn't great, but that looks
like a typo.
Michael Young
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-03-10 17:49 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-03-10 16:49 ` Marc - A. Dahlhaus
2009-03-10 17:49 ` Ian Jackson
2009-03-10 12:28 ` M A Young
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.