@@ -98,19 +98,6 @@ def read_vectors(hash_name):
9898 yield parts
9999
100100
101- def find_gil_minsize (* modules_names , default = 2048 ):
102- sizes = []
103- for module_name in modules_names :
104- if SKIP_SHA3 and module_name == '_sha3' :
105- continue
106- try :
107- module = importlib .import_module (module_name )
108- except ImportError :
109- continue
110- sizes .append (module ._GIL_MINSIZE )
111- return max (sizes , default = default )
112-
113-
114101class HashLibTestCase (unittest .TestCase ):
115102 supported_hash_names = ( 'md5' , 'MD5' , 'sha1' , 'SHA1' ,
116103 'sha224' , 'SHA224' , 'sha256' , 'SHA256' ,
@@ -928,10 +915,10 @@ def test_gil(self):
928915 # for multithreaded operation. Currently, all cryptographic modules
929916 # have the same constant value (2048) but in the future it might not
930917 # be the case.
931- gil_minsize = find_gil_minsize (
932- '_md5' , '_sha1' , '_sha2' , '_sha3' , '_blake2' , '_hashlib' ,
933- )
918+ mods = ['_md5' , '_sha1' , '_sha2' , '_sha3' , '_blake2' , '_hashlib' ]
919+ gil_minsize = hashlib_helper .find_gil_minsize (mods )
934920 for cons in self .hash_constructors :
921+ # constructors belong to one of the above modules
935922 m = cons (usedforsecurity = False )
936923 m .update (b'1' )
937924 m .update (b'#' * gil_minsize )
@@ -941,7 +928,7 @@ def test_gil(self):
941928 m .update (b'1' )
942929
943930 def test_sha256_gil (self ):
944- gil_minsize = find_gil_minsize ('_sha2' , '_hashlib' )
931+ gil_minsize = hashlib_helper . find_gil_minsize ([ '_sha2' , '_hashlib' ] )
945932 m = hashlib .sha256 ()
946933 m .update (b'1' )
947934 m .update (b'#' * gil_minsize )
0 commit comments