don't depend on python2.5 Fixes #3888
This commit is contained in:
parent
a9e25aa98a
commit
96a50f6c07
|
@ -30,7 +30,6 @@ import urllib
|
|||
import errno
|
||||
import select
|
||||
import sha
|
||||
import hashlib
|
||||
import base64
|
||||
import sys
|
||||
from encodings.punycode import punycode_encode
|
||||
|
@ -42,6 +41,18 @@ from i18n import ngettext
|
|||
from xmpp_stringprep import nodeprep, resourceprep, nameprep
|
||||
import xmpp
|
||||
|
||||
try:
|
||||
# Python 2.5
|
||||
import hashlib
|
||||
hash_md5 = hashlib.md5
|
||||
hash_sha1 = hashlib.sha1
|
||||
except:
|
||||
# Python 2.4
|
||||
import md5
|
||||
import sha
|
||||
hash_md5 = md5.new
|
||||
hash_sha1 = sha.new
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
from osx import nsapp
|
||||
|
||||
|
@ -1256,9 +1267,9 @@ def compute_caps_hash(identities, features, hash_method='sha-1'):
|
|||
for f in features:
|
||||
S += '%s<' % f
|
||||
if hash_method == 'sha-1':
|
||||
hash = hashlib.sha1(S)
|
||||
hash = hash_sha1(S)
|
||||
elif hash_method == 'md5':
|
||||
hash = hashlib.md5(S)
|
||||
hash = hash_md5(S)
|
||||
else:
|
||||
return ''
|
||||
return base64.b64encode(hash.digest())
|
||||
|
|
Loading…
Reference in New Issue