Revision: 2183
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=2183&view=rev
Author:   tmzullinger
Date:     2008-12-28 17:20:14 +0000 (Sun, 28 Dec 2008)

Log Message:
-----------
Python: fix sha DeprecationWarning with python-2.6

Modified Paths:
--------------
    libgpod/trunk/ChangeLog
    libgpod/trunk/bindings/python/gtkpod.py

Modified: libgpod/trunk/ChangeLog
===================================================================
--- libgpod/trunk/ChangeLog     2008-12-27 12:49:41 UTC (rev 2182)
+++ libgpod/trunk/ChangeLog     2008-12-28 17:20:14 UTC (rev 2183)
@@ -1,3 +1,9 @@
+2008-12-28  Todd Zullinger  <tmzullinger at users.sourceforge.net>
+
+       * bindings/python/gtkpod.py:
+       Python: fix sha DeprecationWarning with python-2.6 (thanks to
+       Alex Ghitza)
+
 2008-12-26  Todd Zullinger  <tmzullinger at users.sourceforge.net>
 
        * po/es.po: Update Spanish translation (Alejandro Lamas DaviƱa)

Modified: libgpod/trunk/bindings/python/gtkpod.py
===================================================================
--- libgpod/trunk/bindings/python/gtkpod.py     2008-12-27 12:49:41 UTC (rev 
2182)
+++ libgpod/trunk/bindings/python/gtkpod.py     2008-12-28 17:20:14 UTC (rev 
2183)
@@ -1,9 +1,17 @@
 """Read and write Gtkpod extended info files."""
 
-import sha
 import os
 import types
 
+# The hashlib module is only available in python >= 2.5,
+# while the sha module is deprecated in 2.6.
+try:
+    import hashlib
+    sha1 = hashlib.sha1
+except ImportError:
+    import sha
+    sha1 = sha.sha
+
 # This file is originally stolen from pypod-0.5.0
 # http://superduper.net/index.py?page=pypod
 # and reworked significantly since then.
@@ -21,7 +29,7 @@
     import struct
     # only hash the first 16k
     hash_len = 4*4096
-    hash = sha.sha()
+    hash = sha1()
     size = os.path.getsize(filename)
     hash.update(struct.pack("<L", size))
     hash.update(open(filename).read(hash_len))


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to