File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -1693,11 +1693,14 @@ class MyInt(int):
16931693 # GH-117195 -- This shouldn't crash
16941694 object .__sizeof__ (1 )
16951695
1696- def test_long_hash (self ):
1696+ def test_hash (self ):
16971697 # gh-136599
1698- assert hash (10 ) == 10
1699- assert hash (- 1 ) == - 2
1700- assert hash (- 2 ** 61 ) != - 1
1698+ self .assertEqual (hash (- 1 ), - 2 )
1699+ self .assertEqual (hash (10 ), 10 )
1700+ self .assertEqual (hash (2 ** 31 - 1 ), 2 ** 31 - 1 )
1701+ self .assertNotEqual (hash (- 2 ** 31 ), - 1 )
1702+ self .assertNotEqual (hash (- 2 ** 61 ), - 1 )
1703+
17011704
17021705if __name__ == "__main__" :
17031706 unittest .main ()
Original file line number Diff line number Diff line change @@ -3682,11 +3682,12 @@ long_hash(PyObject *obj)
36823682 -- i ;
36833683 x = v -> long_value .ob_digit [i ];
36843684 assert (x < _PyHASH_MODULUS );
3685+ #if ( PyHASH_BITS > (2 * PyLong_SHIFT ))
36853686 -- i ;
36863687 x = ((x << PyLong_SHIFT ));
36873688 x += v -> long_value .ob_digit [i ];
36883689 assert (x < _PyHASH_MODULUS );
3689-
3690+ #endif
36903691 while (-- i >= 0 ) {
36913692 /* Here x is a quantity in the range [0, _PyHASH_MODULUS); we
36923693 want to compute x * 2**PyLong_SHIFT + v->long_value.ob_digit[i] modulo
You can’t perform that action at this time.
0 commit comments