@@ -96,19 +96,6 @@ def read_vectors(hash_name):
9696 yield parts
9797
9898
99- def find_gil_minsize (* modules_names , default = 2048 ):
100- sizes = []
101- for module_name in modules_names :
102- if SKIP_SHA3 and module_name == '_sha3' :
103- continue
104- try :
105- module = importlib .import_module (module_name )
106- except ImportError :
107- continue
108- sizes .append (module ._GIL_MINSIZE )
109- return max (sizes , default = default )
110-
111-
11299class HashLibTestCase (unittest .TestCase ):
113100 supported_hash_names = ( 'md5' , 'MD5' , 'sha1' , 'SHA1' ,
114101 'sha224' , 'SHA224' , 'sha256' , 'SHA256' ,
@@ -930,10 +917,10 @@ def test_gil(self):
930917 # for multithreaded operation. Currently, all cryptographic modules
931918 # have the same constant value (2048) but in the future it might not
932919 # be the case.
933- gil_minsize = find_gil_minsize (
934- '_md5' , '_sha1' , '_sha2' , '_sha3' , '_blake2' , '_hashlib' ,
935- )
920+ mods = ['_md5' , '_sha1' , '_sha2' , '_sha3' , '_blake2' , '_hashlib' ]
921+ gil_minsize = hashlib_helper .find_gil_minsize (mods )
936922 for cons in self .hash_constructors :
923+ # constructors belong to one of the above modules
937924 m = cons (usedforsecurity = False )
938925 m .update (b'1' )
939926 m .update (b'#' * gil_minsize )
@@ -943,7 +930,7 @@ def test_gil(self):
943930 m .update (b'1' )
944931
945932 def test_sha256_gil (self ):
946- gil_minsize = find_gil_minsize ('_sha2' , '_hashlib' )
933+ gil_minsize = hashlib_helper . find_gil_minsize ([ '_sha2' , '_hashlib' ] )
947934 m = hashlib .sha256 ()
948935 m .update (b'1' )
949936 m .update (b'#' * gil_minsize )
0 commit comments