Skip to content

Commit

Permalink
Improved compatibility with Python 2.4
Browse files Browse the repository at this point in the history
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
mludvig committed Jun 10, 2011
1 parent d439efb commit bcb4442
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions S3/Utils.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
## License: GPL Version 2 ## License: GPL Version 2


import os import os
import sys
import time import time
import re import re
import string import string
import random import random
import rfc822 import rfc822
try:
from hashlib import md5, sha1
except ImportError:
from md5 import md5
import sha as sha1
import hmac import hmac
import base64 import base64
import errno import errno
Expand All @@ -23,6 +19,13 @@
import Config import Config
import Exceptions 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: try:
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
except ImportError: except ImportError:
Expand Down

0 comments on commit bcb4442

Please sign in to comment.