diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-11-13 12:33:43 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-11-13 12:33:43 -0800 |
commit | e1a671011993a7ebb73845b3ac12fea80bfc2074 (patch) | |
tree | 966843673ca52f8a798175dae0158f722eda6b9b | |
parent | 57dca075caa03d701b02da68e894e2aec9606db2 (diff) | |
download | portage-e1a671011993a7ebb73845b3ac12fea80bfc2074.tar.gz portage-e1a671011993a7ebb73845b3ac12fea80bfc2074.tar.bz2 portage-e1a671011993a7ebb73845b3ac12fea80bfc2074.zip |
checksum.py: handle pycrypto breakage
-rw-r--r-- | pym/portage/checksum.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py index 8e5abfff2..f10fc4d55 100644 --- a/pym/portage/checksum.py +++ b/pym/portage/checksum.py @@ -99,10 +99,18 @@ except ImportError: pass # Use pycrypto when available, prefer it over the internal fallbacks +# Check for 'new' attributes, since they can be missing if the module +# is broken somehow. try: from Crypto.Hash import SHA256, RIPEMD - sha256hash = _generate_hash_function("SHA256", SHA256.new, origin="pycrypto") - rmd160hash = _generate_hash_function("RMD160", RIPEMD.new, origin="pycrypto") + sha256hash = getattr(SHA256, 'new', None) + if sha256hash is not None: + sha256hash = _generate_hash_function("SHA256", + sha256hash, origin="pycrypto") + rmd160hash = getattr(RIPEMD, 'new', None) + if rmd160hash is not None: + rmd160hash = _generate_hash_function("RMD160", + rmd160hash, origin="pycrypto") except ImportError: pass |