@@ -1102,6 +1102,11 @@ def HMAC(self, key, msg=None):
11021102        """Create a HMAC object.""" 
11031103        raise  NotImplementedError 
11041104
1105+     @property  
1106+     def  gil_minsize (self ):
1107+         """Get the maximal input length for the GIL to be held.""" 
1108+         raise  NotImplementedError 
1109+ 
11051110    def  check_update (self , key , chunks ):
11061111        chunks  =  list (chunks )
11071112        msg  =  b'' .join (chunks )
@@ -1120,11 +1125,10 @@ def test_update(self):
11201125            self .check_update (key , [msg ])
11211126
11221127    def  test_update_large (self ):
1123-         HASHLIB_GIL_MINSIZE  =  2048 
1124- 
1128+         gil_minsize  =  self .gil_minsize 
11251129        key  =  random .randbytes (16 )
1126-         top  =  random .randbytes (HASHLIB_GIL_MINSIZE  +  1 )
1127-         bot  =  random .randbytes (HASHLIB_GIL_MINSIZE  +  1 )
1130+         top  =  random .randbytes (gil_minsize  +  1 )
1131+         bot  =  random .randbytes (gil_minsize  +  1 )
11281132        self .check_update (key , [top , bot ])
11291133
11301134    def  test_update_exceptions (self ):
@@ -1140,13 +1144,21 @@ class PyUpdateTestCase(PyModuleMixin, UpdateTestCaseMixin, unittest.TestCase):
11401144    def  HMAC (self , key , msg = None ):
11411145        return  self .hmac .HMAC (key , msg , digestmod = 'sha256' )
11421146
1147+     @property  
1148+     def  gil_minsize (self ):
1149+         self .skipTest ("GIL is always held" )
1150+ 
11431151
11441152@hashlib_helper .requires_openssl_hashdigest ('sha256' ) 
11451153class  OpenSSLUpdateTestCase (UpdateTestCaseMixin , unittest .TestCase ):
11461154
11471155    def  HMAC (self , key , msg = None ):
11481156        return  _hashlib .hmac_new (key , msg , digestmod = 'sha256' )
11491157
1158+     @property  
1159+     def  gil_minsize (self ):
1160+         return  _hashlib .GIL_MINSIZE 
1161+ 
11501162
11511163class  BuiltinUpdateTestCase (BuiltinModuleMixin ,
11521164                            UpdateTestCaseMixin , unittest .TestCase ):
@@ -1156,6 +1168,10 @@ def HMAC(self, key, msg=None):
11561168        # are still built, making it possible to use SHA-2 hashes. 
11571169        return  self .hmac .new (key , msg , digestmod = 'sha256' )
11581170
1171+     @property  
1172+     def  gil_minsize (self ):
1173+         return  self .hmac .GIL_MINSIZE 
1174+ 
11591175
11601176class  CopyBaseTestCase :
11611177
0 commit comments