mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-43475: Fix worst case collision behavior for NaN instances (GH-25493)
This commit is contained in:
parent
accea7dc2b
commit
a07da09ad5
10 changed files with 25 additions and 21 deletions
|
@ -4536,7 +4536,6 @@ _dec_hash(PyDecObject *v)
|
|||
#error "No valid combination of CONFIG_64, CONFIG_32 and _PyHASH_BITS"
|
||||
#endif
|
||||
const Py_hash_t py_hash_inf = 314159;
|
||||
const Py_hash_t py_hash_nan = 0;
|
||||
mpd_uint_t ten_data[1] = {10};
|
||||
mpd_t ten = {MPD_POS|MPD_STATIC|MPD_CONST_DATA,
|
||||
0, 2, 1, 1, ten_data};
|
||||
|
@ -4555,7 +4554,7 @@ _dec_hash(PyDecObject *v)
|
|||
return -1;
|
||||
}
|
||||
else if (mpd_isnan(MPD(v))) {
|
||||
return py_hash_nan;
|
||||
return _Py_HashPointer(v);
|
||||
}
|
||||
else {
|
||||
return py_hash_inf * mpd_arith_sign(MPD(v));
|
||||
|
@ -5939,5 +5938,3 @@ error:
|
|||
|
||||
return NULL; /* GCOV_NOT_REACHED */
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue