From: Zac Medico Date: Sun, 13 Nov 2011 20:33:43 +0000 (-0800) Subject: checksum.py: handle pycrypto breakage X-Git-Tag: v2.2.0_alpha75~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e1a671011993a7ebb73845b3ac12fea80bfc2074;p=portage.git checksum.py: handle pycrypto breakage --- 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