1 |
commit: 06ad8911b5790a2ed963fe1b981751ab0a2be8d5 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Oct 2 06:01:17 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Oct 2 06:01:17 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=06ad8911 |
7 |
|
8 |
checksum.py: lazily import bundled whirlpool |
9 |
|
10 |
--- |
11 |
pym/portage/checksum.py | 14 +++++++------- |
12 |
1 files changed, 7 insertions(+), 7 deletions(-) |
13 |
|
14 |
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py |
15 |
index a4a744b..080a6df 100644 |
16 |
--- a/pym/portage/checksum.py |
17 |
+++ b/pym/portage/checksum.py |
18 |
@@ -76,10 +76,6 @@ except ImportError: |
19 |
|
20 |
sha1hash = _generate_hash_function("SHA1", _new_sha1, origin="internal") |
21 |
|
22 |
-# Bundled WHIRLPOOL implementation |
23 |
-from portage.util.whirlpool import new as _new_whirlpool |
24 |
-whirlpoolhash = _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled") |
25 |
- |
26 |
# Try to use mhash if available |
27 |
# mhash causes GIL presently, so it gets less priority than hashlib and |
28 |
# pycrypto. However, it might be the only accelerated implementation of |
29 |
@@ -104,7 +100,7 @@ try: |
30 |
from Crypto.Hash import SHA256, RIPEMD |
31 |
sha256hash = _generate_hash_function("SHA256", SHA256.new, origin="pycrypto") |
32 |
rmd160hash = _generate_hash_function("RMD160", RIPEMD.new, origin="pycrypto") |
33 |
-except ImportError as e: |
34 |
+except ImportError: |
35 |
pass |
36 |
|
37 |
# Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks. |
38 |
@@ -127,9 +123,13 @@ try: |
39 |
functools.partial(hashlib.new, hash_name), \ |
40 |
origin='hashlib') |
41 |
|
42 |
-except ImportError as e: |
43 |
+except ImportError: |
44 |
pass |
45 |
- |
46 |
+ |
47 |
+if "WHIRLPOOL" not in hashfunc_map: |
48 |
+ # Bundled WHIRLPOOL implementation |
49 |
+ from portage.util.whirlpool import new as _new_whirlpool |
50 |
+ whirlpoolhash = _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled") |
51 |
|
52 |
# Use python-fchksum if available, prefer it over all other MD5 implementations |
53 |
try: |