Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH 2/3] checksum: Remove redundant internal fallbacks
Date: Tue, 28 Feb 2017 09:02:44
Message-Id: 20170228090155.868-3-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCHES] Little cleanup of checksum + BLAKE2*/SHA3 by "Michał Górny"
1 Remove the internal digest fallbacks since they have no real use
2 nowadays. The hashlib versions are preferred later in the logic anyway,
3 and they are available since Python 2.5.
4 ---
5 pym/portage/checksum.py | 19 ++-----------------
6 1 file changed, 2 insertions(+), 17 deletions(-)
7
8 diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
9 index 319252315..8b4d96e30 100644
10 --- a/pym/portage/checksum.py
11 +++ b/pym/portage/checksum.py
12 @@ -18,8 +18,8 @@ import tempfile
13 # most preferred first. Please keep this in sync with logic below.
14 # ================================================================
15 #
16 -# MD5: python-fchksum, hashlib, mhash, hashlib/md5
17 -# SHA1: hashlib, mhash, hashlib/sha1
18 +# MD5: python-fchksum, hashlib, mhash
19 +# SHA1: hashlib, mhash
20 # SHA256: hashlib, pycrypto, mhash
21 # SHA512: hashlib, mhash
22 # RMD160: hashlib, pycrypto, mhash
23 @@ -77,21 +77,6 @@ class _generate_hash_function(object):
24 # Define hash functions, try to use the best module available. Later definitions
25 # override earlier ones
26
27 -# Use the internal modules as last fallback
28 -try:
29 - from hashlib import md5 as _new_md5
30 -except ImportError:
31 - from md5 import new as _new_md5
32 -
33 -md5hash = _generate_hash_function("MD5", _new_md5, origin="internal")
34 -
35 -try:
36 - from hashlib import sha1 as _new_sha1
37 -except ImportError:
38 - from sha import new as _new_sha1
39 -
40 -sha1hash = _generate_hash_function("SHA1", _new_sha1, origin="internal")
41 -
42 # Try to use mhash if available
43 # mhash causes GIL presently, so it gets less priority than hashlib and
44 # pycrypto. However, it might be the only accelerated implementation of
45 --
46 2.12.0

Replies