diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-07-17 11:28:44 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-07-17 11:28:44 -0400 |
commit | 3e72e7f7eacca7db638f7230f93cf696d49c77bf (patch) | |
tree | 5e696d38763d9ec86ec7ec583ee974ea886029e1 /setuptools/package_index.py | |
parent | d00b66d5f530da930fdd89cdfdf0ff954f88a141 (diff) | |
download | external_python_setuptools-3e72e7f7eacca7db638f7230f93cf696d49c77bf.tar.gz external_python_setuptools-3e72e7f7eacca7db638f7230f93cf696d49c77bf.tar.bz2 external_python_setuptools-3e72e7f7eacca7db638f7230f93cf696d49c77bf.zip |
Add compatibility for Python 2.4 when querying the hash name. Fixes #440.9.6
Diffstat (limited to 'setuptools/package_index.py')
-rwxr-xr-x | setuptools/package_index.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py index 70aabd1b..47f00c00 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -242,8 +242,23 @@ class HashChecker(ContentChecker): def is_valid(self): return self.hash.hexdigest() == self.expected + def _get_hash_name(self): + """ + Python 2.4 implementation of MD5 doesn't supply a .name attribute + so provide that name. + + When Python 2.4 is no longer required, replace invocations of this + method with simply 'self.hash.name'. + """ + try: + return self.hash.name + except AttributeError: + if 'md5' in str(type(self.hash)): + return 'md5' + raise + def report(self, reporter, template): - msg = template % self.hash.name + msg = template % self._get_hash_name() return reporter(msg) |