diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -19,9 +19,6 @@ import warnings from test import support from test.support import _4G, bigmemtest -# Were we compiled --with-pydebug or with #define Py_DEBUG? -COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount') - def hexstr(s): assert isinstance(s, bytes), repr(s) @@ -37,7 +34,7 @@ class HashLibTestCase(unittest.TestCase) 'sha224', 'SHA224', 'sha256', 'SHA256', 'sha384', 'SHA384', 'sha512', 'SHA512' ) - _warn_on_extension_import = COMPILED_WITH_PYDEBUG + _warn_on_extension_import = True def _conditional_import_module(self, module_name): """Import a module and return a reference to it or None on failure.""" diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -749,20 +749,17 @@ class PyBuildExt(build_ext): openssl_ver) missing.append('_hashlib') - min_sha2_openssl_ver = 0x00908000 - if COMPILED_WITH_PYDEBUG or openssl_ver < min_sha2_openssl_ver: - # OpenSSL doesn't do these until 0.9.8 so we'll bring our own hash - exts.append( Extension('_sha256', ['sha256module.c'], - depends=['hashlib.h']) ) - exts.append( Extension('_sha512', ['sha512module.c'], - depends=['hashlib.h']) ) - - if COMPILED_WITH_PYDEBUG or not have_usable_openssl: - # no openssl at all, use our own md5 and sha1 - exts.append( Extension('_md5', ['md5module.c'], - depends=['hashlib.h']) ) - exts.append( Extension('_sha1', ['sha1module.c'], - depends=['hashlib.h']) ) + # We always compile these even when OpenSSL is available (issue #14693). + # It's harmless and the object code is tiny (40-50 KB per module, + # only loaded when actually used). + exts.append( Extension('_sha256', ['sha256module.c'], + depends=['hashlib.h']) ) + exts.append( Extension('_sha512', ['sha512module.c'], + depends=['hashlib.h']) ) + exts.append( Extension('_md5', ['md5module.c'], + depends=['hashlib.h']) ) + exts.append( Extension('_sha1', ['sha1module.c'], + depends=['hashlib.h']) ) # Modules that provide persistent dictionary-like semantics. You will # probably want to arrange for at least one of them to be available on