]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #14693: Under non-Windows platforms, hashlib's fallback modules are always...
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 16 May 2012 14:41:26 +0000 (16:41 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 16 May 2012 14:41:26 +0000 (16:41 +0200)
Lib/test/test_hashlib.py
Misc/NEWS
setup.py

index 97981dd20d55f7e3fa48049505f18f16cb88ad35..ce8175a505fbd2784db148f180cfc78fc731e0fc 100644 (file)
@@ -9,6 +9,7 @@
 import array
 import hashlib
 import itertools
+import os
 import sys
 try:
     import threading
@@ -37,7 +38,8 @@ class HashLibTestCase(unittest.TestCase):
                              'sha224', 'SHA224', 'sha256', 'SHA256',
                              'sha384', 'SHA384', 'sha512', 'SHA512' )
 
-    _warn_on_extension_import = COMPILED_WITH_PYDEBUG
+    # Issue #14693: fallback modules are always compiled under POSIX
+    _warn_on_extension_import = os.name == 'posix' or COMPILED_WITH_PYDEBUG
 
     def _conditional_import_module(self, module_name):
         """Import a module and return a reference to it or None on failure."""
index b289b54ed0868f13a497f2ab2f13f8d5e3245021..da919aa3371474d2ef80646e94ee1031eaf7a76b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -125,6 +125,9 @@ Tools/Demos
 Build
 -----
 
+- Issue #14693: Under non-Windows platforms, hashlib's fallback modules are
+  always compiled, even if OpenSSL is present at build time.
+
 - Issue #13210: Windows build now uses VS2010, ported from VS2008.
 
 
index f7a8a65975108228c1d5a3dab6d8d85c17c77b6d..155156b6dcd146d5f2d6387b55b6b9d4f37df5aa 100644 (file)
--- 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