From e1a671011993a7ebb73845b3ac12fea80bfc2074 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 13 Nov 2011 12:33:43 -0800 Subject: checksum.py: handle pycrypto breakage --- pym/portage/checksum.py | 12 ++++++++++-- 1 file 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 -- cgit v1.2.3-1-g7c22