@@ -98,19 +98,6 @@ def read_vectors(hash_name):
98
98
yield parts
99
99
100
100
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
-
114
101
class HashLibTestCase (unittest .TestCase ):
115
102
supported_hash_names = ( 'md5' , 'MD5' , 'sha1' , 'SHA1' ,
116
103
'sha224' , 'SHA224' , 'sha256' , 'SHA256' ,
@@ -928,10 +915,10 @@ def test_gil(self):
928
915
# for multithreaded operation. Currently, all cryptographic modules
929
916
# have the same constant value (2048) but in the future it might not
930
917
# 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 )
934
920
for cons in self .hash_constructors :
921
+ # constructors belong to one of the above modules
935
922
m = cons (usedforsecurity = False )
936
923
m .update (b'1' )
937
924
m .update (b'#' * gil_minsize )
@@ -941,7 +928,7 @@ def test_gil(self):
941
928
m .update (b'1' )
942
929
943
930
def test_sha256_gil (self ):
944
- gil_minsize = find_gil_minsize ('_sha2' , '_hashlib' )
931
+ gil_minsize = hashlib_helper . find_gil_minsize ([ '_sha2' , '_hashlib' ] )
945
932
m = hashlib .sha256 ()
946
933
m .update (b'1' )
947
934
m .update (b'#' * gil_minsize )
0 commit comments