File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -1696,10 +1696,18 @@ class MyInt(int):
16961696 def test_hash (self ):
16971697 # gh-136599
16981698 self .assertEqual (hash (- 1 ), - 2 )
1699+ self .assertEqual (hash (0 ), 0 )
16991700 self .assertEqual (hash (10 ), 10 )
1700- self .assertEqual (hash (2 ** 31 - 2 ), 2 ** 31 - 2 )
1701- self .assertNotEqual (hash (- 2 ** 31 ), - 1 )
1702- self .assertNotEqual (hash (- 2 ** 61 ), - 1 )
1701+
1702+ self .assertEqual (hash (sys .hash_info .modulus - 2 ), sys .hash_info .modulus - 2 )
1703+ self .assertEqual (hash (sys .hash_info .modulus - 1 ), sys .hash_info .modulus - 1 )
1704+ self .assertEqual (hash (sys .hash_info .modulus ), 0 )
1705+ self .assertEqual (hash (sys .hash_info .modulus + 1 ), 1 )
1706+
1707+ self .assertEqual (hash (- sys .hash_info .modulus - 2 ), - 2 )
1708+ self .assertEqual (hash (- sys .hash_info .modulus - 1 ), - 2 )
1709+ self .assertEqual (hash (- sys .hash_info .modulus ), 0 )
1710+ self .assertEqual (hash (- sys .hash_info .modulus + 1 ), - (sys .hash_info .modulus - 1 ))
17031711
17041712
17051713if __name__ == "__main__" :
Original file line number Diff line number Diff line change @@ -3678,11 +3678,13 @@ long_hash(PyObject *obj)
36783678 sign = _PyLong_NonCompactSign (v );
36793679
36803680 // unroll first two digits
3681+ #if ( PyHASH_BITS > PyLong_SHIFT )
36813682 assert (i >=2 );
36823683 -- i ;
36833684 x = v -> long_value .ob_digit [i ];
36843685 assert (x < _PyHASH_MODULUS );
3685- #if ( PyHASH_BITS > (2 * PyLong_SHIFT ))
3686+ #endif
3687+ #if ( PyHASH_BITS > (2 * PyLong_SHIFT ) )
36863688 -- i ;
36873689 x = ((x << PyLong_SHIFT ));
36883690 x += v -> long_value .ob_digit [i ];
You can’t perform that action at this time.
0 commit comments