@@ -1169,7 +1169,7 @@ def testInterfaceNameIndex(self):
11691169    @support .skip_android_selinux ('if_indextoname' ) 
11701170    def  testInvalidInterfaceIndexToName (self ):
11711171        self .assertRaises (OSError , socket .if_indextoname , 0 )
1172-         self .assertRaises (OverflowError , socket .if_indextoname , - 1 )
1172+         self .assertRaises (ValueError , socket .if_indextoname , - 1 )
11731173        self .assertRaises (OverflowError , socket .if_indextoname , 2 ** 1000 )
11741174        self .assertRaises (TypeError , socket .if_indextoname , '_DEADBEEF' )
11751175        if  hasattr (socket , 'if_nameindex' ):
@@ -1231,18 +1231,22 @@ def testNtoHErrors(self):
12311231        import  _testcapi 
12321232        s_good_values  =  [0 , 1 , 2 , 0xffff ]
12331233        l_good_values  =  s_good_values  +  [0xffffffff ]
1234-         l_bad_values  =  [- 1 ,  - 2 ,  1 << 32 , 1 << 1000 ]
1234+         l_bad_values  =  [1 << 32 , 1 << 1000 ]
12351235        s_bad_values  =  (
12361236            l_bad_values  + 
1237-             [_testcapi .INT_MIN - 1 , _testcapi .INT_MAX + 1 ] + 
1238-             [1  <<  16 , _testcapi .INT_MAX ]
1237+             [1  <<  16 , _testcapi .INT_MAX , _testcapi .INT_MAX + 1 ]
12391238        )
12401239        for  k  in  s_good_values :
12411240            socket .ntohs (k )
12421241            socket .htons (k )
12431242        for  k  in  l_good_values :
12441243            socket .ntohl (k )
12451244            socket .htonl (k )
1245+         for  k  in  - 1 , - 2 , _testcapi .INT_MIN - 1 , - 1 << 1000 :
1246+             self .assertRaises (ValueError , socket .ntohs , k )
1247+             self .assertRaises (ValueError , socket .ntohl , k )
1248+             self .assertRaises (ValueError , socket .htons , k )
1249+             self .assertRaises (ValueError , socket .htonl , k )
12461250        for  k  in  s_bad_values :
12471251            self .assertRaises (OverflowError , socket .ntohs , k )
12481252            self .assertRaises (OverflowError , socket .htons , k )
0 commit comments