diff options
author | Todd Zullinger <tmz@pobox.com> | 2008-12-28 17:20:14 +0000 |
---|---|---|
committer | Todd Zullinger <tmz@pobox.com> | 2008-12-28 17:20:14 +0000 |
commit | 32c7c2a315394f23136f4ef3ec4ec4421126837a (patch) | |
tree | 8118c8faf3cfaf98453fffd3fd4c06d7c126ec6f | |
parent | 5e3c073ea32c15e95e6d9172ee80aa84c7b16819 (diff) | |
download | libgpod-tmz-32c7c2a315394f23136f4ef3ec4ec4421126837a.tar.gz libgpod-tmz-32c7c2a315394f23136f4ef3ec4ec4421126837a.tar.xz libgpod-tmz-32c7c2a315394f23136f4ef3ec4ec4421126837a.zip |
Python: fix sha DeprecationWarning with python-2.6
git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@2183 f01d2545-417e-4e96-918e-98f8d0dbbcb6
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | bindings/python/gtkpod.py | 12 |
2 files changed, 16 insertions, 2 deletions
@@ -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) diff --git a/bindings/python/gtkpod.py b/bindings/python/gtkpod.py index 64e50f2..83193f5 100644 --- a/bindings/python/gtkpod.py +++ b/bindings/python/gtkpod.py @@ -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 @@ def sha1_hash(filename): 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)) |