mirror of
https://github.com/python/cpython.git
synced 2025-09-17 06:06:25 +00:00
Always compile the all versions of the hashlib algorithm modules when Python
was compiled with Py_DEBUG defined. Otherwise the builtins are not compiled by default for many developers due to OpenSSL being present, making it easier for bugs to slip by. A future commit will add test code compare the behaviors of all implementations when they are all available.
This commit is contained in:
parent
b538d546da
commit
c2fa18ca20
1 changed files with 11 additions and 5 deletions
16
setup.py
16
setup.py
|
@ -16,6 +16,9 @@ from distutils.command.build_ext import build_ext
|
||||||
from distutils.command.install import install
|
from distutils.command.install import install
|
||||||
from distutils.command.install_lib import install_lib
|
from distutils.command.install_lib import install_lib
|
||||||
|
|
||||||
|
# Were we compiled --with-pydebug or with #define Py_DEBUG?
|
||||||
|
COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
|
||||||
|
|
||||||
# This global variable is used to hold the list of modules to be disabled.
|
# This global variable is used to hold the list of modules to be disabled.
|
||||||
disabled_module_list = []
|
disabled_module_list = []
|
||||||
|
|
||||||
|
@ -653,10 +656,12 @@ class PyBuildExt(build_ext):
|
||||||
break
|
break
|
||||||
|
|
||||||
#print 'openssl_ver = 0x%08x' % openssl_ver
|
#print 'openssl_ver = 0x%08x' % openssl_ver
|
||||||
|
min_openssl_ver = 0x00907000
|
||||||
if (ssl_incs is not None and
|
have_usable_openssl = (ssl_incs is not None and
|
||||||
ssl_libs is not None and
|
ssl_libs is not None and
|
||||||
openssl_ver >= 0x00907000):
|
openssl_ver >= min_openssl_ver)
|
||||||
|
|
||||||
|
if have_usable_openssl:
|
||||||
# The _hashlib module wraps optimized implementations
|
# The _hashlib module wraps optimized implementations
|
||||||
# of hash functions from the OpenSSL library.
|
# of hash functions from the OpenSSL library.
|
||||||
exts.append( Extension('_hashlib', ['_hashopenssl.c'],
|
exts.append( Extension('_hashlib', ['_hashopenssl.c'],
|
||||||
|
@ -665,7 +670,7 @@ class PyBuildExt(build_ext):
|
||||||
libraries = ['ssl', 'crypto']) )
|
libraries = ['ssl', 'crypto']) )
|
||||||
# these aren't strictly missing since they are unneeded.
|
# these aren't strictly missing since they are unneeded.
|
||||||
#missing.extend(['_sha', '_md5'])
|
#missing.extend(['_sha', '_md5'])
|
||||||
else:
|
if COMPILED_WITH_PYDEBUG or not have_usable_openssl:
|
||||||
# The _sha module implements the SHA1 hash algorithm.
|
# The _sha module implements the SHA1 hash algorithm.
|
||||||
exts.append( Extension('_sha', ['shamodule.c']) )
|
exts.append( Extension('_sha', ['shamodule.c']) )
|
||||||
# The _md5 module implements the RSA Data Security, Inc. MD5
|
# The _md5 module implements the RSA Data Security, Inc. MD5
|
||||||
|
@ -676,7 +681,8 @@ class PyBuildExt(build_ext):
|
||||||
depends = ['md5.h']) )
|
depends = ['md5.h']) )
|
||||||
missing.append('_hashlib')
|
missing.append('_hashlib')
|
||||||
|
|
||||||
if (openssl_ver < 0x00908000):
|
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
|
# OpenSSL doesn't do these until 0.9.8 so we'll bring our own hash
|
||||||
exts.append( Extension('_sha256', ['sha256module.c']) )
|
exts.append( Extension('_sha256', ['sha256module.c']) )
|
||||||
exts.append( Extension('_sha512', ['sha512module.c']) )
|
exts.append( Extension('_sha512', ['sha512module.c']) )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue