]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] bpo-40637: Do not emit warnings for disabled builtin hashes (GH… (GH-20951)
authorstratakis <cstratak@redhat.com>
Wed, 17 Jun 2020 19:43:27 +0000 (21:43 +0200)
committerGitHub <noreply@github.com>
Wed, 17 Jun 2020 19:43:27 +0000 (12:43 -0700)
…-20937)

test_hashlib emits some warnings when it cannot find some hashes
as it assumes they failed to compile. Since we can disable hashes
through configure, we emit the warnings only in the case that we
did not intentionaly disable them.

Automerge-Triggered-By: @tiran
(cherry picked from commit 236a0f5)

Co-authored-by: stratakis <cstratak@redhat.com>
Lib/test/test_hashlib.py

index 6088307f8410b14d893a9aabf7bfd944df1b9a3e..86f20a7aff83afb1dacadb09731238a1e7ce9e10 100644 (file)
@@ -102,7 +102,7 @@ class HashLibTestCase(unittest.TestCase):
         try:
             return importlib.import_module(module_name)
         except ModuleNotFoundError as error:
-            if self._warn_on_extension_import:
+            if self._warn_on_extension_import and module_name in builtin_hashes:
                 warnings.warn('Did a C extension fail to compile? %s' % error)
         return None