summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/checksum.py12
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