commit: d8c8d84f07a299b66dbd38ac7a294989d1315040
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 20 03:26:28 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Mar 21 02:30:24 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d8c8d84f
checksum: drop < Python 3.6 checksum compatibilty via pyblake2, sha3
We've only supported >= Python 3.6 for quite some time, so these codepaths are
obsolete given hashlib will always provide support for BLAKE2 and SHA3.
Neither pyblake2 nor sha3 are even packaged in Gentoo anymore either (the
Python bindings).
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/checksum.py | 33 +++++----------------------------
1 file changed, 5 insertions(+), 28 deletions(-)
diff --git a/lib/portage/checksum.py b/lib/portage/checksum.py
index fdb8387a7..1797f268a 100644
--- a/lib/portage/checksum.py
+++ b/lib/portage/checksum.py
@@ -27,10 +27,10 @@ from portage.localization import _
# SHA512: hashlib
# RMD160: hashlib, pycrypto, mhash
# WHIRLPOOL: hashlib, mhash, bundled
-# BLAKE2B (512): hashlib (3.6+), pyblake2, pycrypto
-# BLAKE2S (512): hashlib (3.6+), pyblake2, pycrypto
-# SHA3_256: hashlib (3.6+), pysha3, pycrypto
-# SHA3_512: hashlib (3.6+), pysha3, pycrypto
+# BLAKE2B (512): hashlib, pycrypto
+# BLAKE2S (512): hashlib,pycrypto
+# SHA3_256: hashlib, pycrypto
+# SHA3_512: hashlib, pycrypto
# Dict of all available hash functions
@@ -101,7 +101,7 @@ class _generate_hash_function:
# already defined.
-# Use hashlib from python-2.5 if available and prefer it over pycrypto and
internal fallbacks.
+# Use hashlib if available and prefer it over pycrypto and internal fallbacks.
# Need special handling for RMD160/WHIRLPOOL as they may not always be
provided by hashlib.
_generate_hash_function("MD5", hashlib.md5, origin="hashlib")
_generate_hash_function("SHA1", hashlib.sha1, origin="hashlib")
@@ -110,7 +110,6 @@ _generate_hash_function("SHA512", hashlib.sha512,
origin="hashlib")
for local_name, hash_name in (
("RMD160", "ripemd160"),
("WHIRLPOOL", "whirlpool"),
- # available since Python 3.6
("BLAKE2B", "blake2b"),
("BLAKE2S", "blake2s"),
("SHA3_256", "sha3_256"),
@@ -126,28 +125,6 @@ for local_name, hash_name in (
)
-# Support using pyblake2 as fallback for python<3.6
-if "BLAKE2B" not in hashfunc_map or "BLAKE2S" not in hashfunc_map:
- try:
- import pyblake2
-
- _generate_hash_function("BLAKE2B", pyblake2.blake2b, origin="pyblake2")
- _generate_hash_function("BLAKE2S", pyblake2.blake2s, origin="pyblake2")
- except ImportError:
- pass
-
-
-# Support using pysha3 as fallback for python<3.6
-if "SHA3_256" not in hashfunc_map or "SHA3_512" not in hashfunc_map:
- try:
- import sha3
-
- _generate_hash_function("SHA3_256", sha3.sha3_256, origin="pysha3")
- _generate_hash_function("SHA3_512", sha3.sha3_512, origin="pysha3")
- 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.