@@ -1100,6 +1100,11 @@ def HMAC(self, key, msg=None):
11001100        """Create a HMAC object.""" 
11011101        raise  NotImplementedError 
11021102
1103+     @property  
1104+     def  gil_minsize (self ):
1105+         """Get the maximal input length for the GIL to be held.""" 
1106+         raise  NotImplementedError 
1107+ 
11031108    def  check_update (self , key , chunks ):
11041109        chunks  =  list (chunks )
11051110        msg  =  b'' .join (chunks )
@@ -1118,11 +1123,10 @@ def test_update(self):
11181123            self .check_update (key , [msg ])
11191124
11201125    def  test_update_large (self ):
1121-         HASHLIB_GIL_MINSIZE  =  2048 
1122- 
1126+         gil_minsize  =  self .gil_minsize 
11231127        key  =  random .randbytes (16 )
1124-         top  =  random .randbytes (HASHLIB_GIL_MINSIZE  +  1 )
1125-         bot  =  random .randbytes (HASHLIB_GIL_MINSIZE  +  1 )
1128+         top  =  random .randbytes (gil_minsize  +  1 )
1129+         bot  =  random .randbytes (gil_minsize  +  1 )
11261130        self .check_update (key , [top , bot ])
11271131
11281132    def  test_update_exceptions (self ):
@@ -1132,19 +1136,27 @@ def test_update_exceptions(self):
11321136                self .assertRaises (TypeError , h .update , msg )
11331137
11341138
1135- @hashlib_helper . requires_hashdigest ( 'sha256' ) 
1139+ @requires_builtin_sha2 ( ) 
11361140class  PyUpdateTestCase (PyModuleMixin , UpdateTestCaseMixin , unittest .TestCase ):
11371141
11381142    def  HMAC (self , key , msg = None ):
11391143        return  self .hmac .HMAC (key , msg , digestmod = 'sha256' )
11401144
1145+     @property  
1146+     def  gil_minsize (self ):
1147+         return  sha2 ._GIL_MINSIZE 
1148+ 
11411149
11421150@hashlib_helper .requires_openssl_hashdigest ('sha256' ) 
11431151class  OpenSSLUpdateTestCase (UpdateTestCaseMixin , unittest .TestCase ):
11441152
11451153    def  HMAC (self , key , msg = None ):
11461154        return  _hashlib .hmac_new (key , msg , digestmod = 'sha256' )
11471155
1156+     @property  
1157+     def  gil_minsize (self ):
1158+         return  _hashlib ._GIL_MINSIZE 
1159+ 
11481160
11491161class  BuiltinUpdateTestCase (BuiltinModuleMixin ,
11501162                            UpdateTestCaseMixin , unittest .TestCase ):
@@ -1154,6 +1166,10 @@ def HMAC(self, key, msg=None):
11541166        # are still built, making it possible to use SHA-2 hashes. 
11551167        return  self .hmac .new (key , msg , digestmod = 'sha256' )
11561168
1169+     @property  
1170+     def  gil_minsize (self ):
1171+         return  self .hmac ._GIL_MINSIZE 
1172+ 
11571173
11581174class  CopyBaseTestCase :
11591175
0 commit comments