From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id F24B8139695 for ; Mon, 13 Mar 2017 21:47:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4222A21C075; Mon, 13 Mar 2017 21:46:49 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 1D3F721C075 for ; Mon, 13 Mar 2017 21:46:49 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3506E34112A for ; Mon, 13 Mar 2017 21:46:48 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C0EF4673B for ; Mon, 13 Mar 2017 21:46:45 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1489441589.42fa52af521867b45b56f091c91b7b6aa78ba677.mgorny@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/checksum.py X-VCS-Directories: pym/portage/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 42fa52af521867b45b56f091c91b7b6aa78ba677 X-VCS-Branch: master Date: Mon, 13 Mar 2017 21:46:45 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 61ad68a2-5c97-4857-9b25-9d28ce40c4f1 X-Archives-Hash: 33541370766dade7c9c38a6deab002e6 commit: 42fa52af521867b45b56f091c91b7b6aa78ba677 Author: Michał Górny gentoo org> AuthorDate: Sun Mar 12 15:33:28 2017 +0000 Commit: Michał Górny gentoo org> CommitDate: Mon Mar 13 21:46:29 2017 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=42fa52af portage.checksum: Remove fallbacks for algorithms guaranteed since py2.7 The MD5, SHA1 and SHA2 algorithms are guaranteed to be available in hashlib for Python 2.7 and newer, making the fallbacks to other implementations meaningless. Remove them to simplify the code. pym/portage/checksum.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py index 82e8bec00..7812791ad 100644 --- a/pym/portage/checksum.py +++ b/pym/portage/checksum.py @@ -19,10 +19,10 @@ import tempfile # most preferred first. Please keep this in sync with logic below. # ================================================================ # -# MD5: hashlib, mhash -# SHA1: hashlib, mhash -# SHA256: hashlib, pycrypto, mhash -# SHA512: hashlib, mhash +# MD5: hashlib +# SHA1: hashlib +# SHA256: hashlib +# SHA512: hashlib # RMD160: hashlib, pycrypto, mhash # WHIRLPOOL: hashlib, mhash, bundled # BLAKE2B (512): hashlib (3.6+), pycrypto @@ -100,10 +100,6 @@ class _generate_hash_function(object): # WHIRLPOOL available. try: import mhash, functools - md5hash = _generate_hash_function("MD5", functools.partial(mhash.MHASH, mhash.MHASH_MD5), origin="mhash") - sha1hash = _generate_hash_function("SHA1", functools.partial(mhash.MHASH, mhash.MHASH_SHA1), origin="mhash") - sha256hash = _generate_hash_function("SHA256", functools.partial(mhash.MHASH, mhash.MHASH_SHA256), origin="mhash") - sha512hash = _generate_hash_function("SHA512", functools.partial(mhash.MHASH, mhash.MHASH_SHA512), origin="mhash") for local_name, hash_name in (("rmd160", "ripemd160"), ("whirlpool", "whirlpool")): if hasattr(mhash, 'MHASH_%s' % local_name.upper()): globals()['%shash' % local_name] = \ @@ -117,11 +113,7 @@ except ImportError: # Check for 'new' attributes, since they can be missing if the module # is broken somehow. try: - from Crypto.Hash import SHA256, RIPEMD - sha256hash_ = getattr(SHA256, 'new', None) - if sha256hash_ is not None: - sha256hash = _generate_hash_function("SHA256", - sha256hash_, origin="pycrypto") + from Crypto.Hash import RIPEMD rmd160hash_ = getattr(RIPEMD, 'new', None) if rmd160hash_ is not None: rmd160hash = _generate_hash_function("RMD160",