Permalink
Browse files

Improved compatibility with Python 2.4

python-hashlib backported to Python 2.4 is not compatible with 'hmac'
module (at least the package distributed with RHEL/CentOS 5 is not).

Use md5 and sha modules on 2.4 regardless if hashlib is present.
  • Loading branch information...
1 parent d439efb commit bcb444200b6eee778b3a640e64695c857fc42ee2 @mludvig mludvig committed Jun 10, 2011
Showing with 8 additions and 5 deletions.
  1. +8 −5 S3/Utils.py
View
13 S3/Utils.py
@@ -4,16 +4,12 @@
## License: GPL Version 2
import os
+import sys
import time
import re
import string
import random
import rfc822
-try:
- from hashlib import md5, sha1
-except ImportError:
- from md5 import md5
- import sha as sha1
import hmac
import base64
import errno
@@ -23,6 +19,13 @@
import Config
import Exceptions
+# hashlib backported to python 2.4 / 2.5 is not compatible with hmac!
+if sys.version_info[0] == 2 and sys.version_info[1] < 6:
+ from md5 import md5
+ import sha as sha1
+else:
+ from hashlib import md5, sha1
+
try:
import xml.etree.ElementTree as ET
except ImportError:

0 comments on commit bcb4442

Please sign in to comment.