File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -582,8 +582,6 @@ def test_hash(self):
582582 self .assertEqual (hash (float ('inf' )), sys .hash_info .inf )
583583 self .assertEqual (hash (float ('-inf' )), - sys .hash_info .inf )
584584
585- # TODO: RUSTPYTHON
586- @unittest .expectedFailure
587585 def test_hash_nan (self ):
588586 value = float ('nan' )
589587 self .assertEqual (hash (value ), object .__hash__ (value ))
Original file line number Diff line number Diff line change @@ -539,7 +539,11 @@ impl Comparable for PyFloat {
539539impl Hashable for PyFloat {
540540 #[ inline]
541541 fn hash ( zelf : & crate :: Py < Self > , _vm : & VirtualMachine ) -> PyResult < hash:: PyHash > {
542- Ok ( hash:: hash_float ( zelf. to_f64 ( ) ) )
542+ if zelf. to_f64 ( ) . is_nan ( ) {
543+ Ok ( zelf. get_id ( ) as hash:: PyHash )
544+ } else {
545+ Ok ( hash:: hash_float ( zelf. to_f64 ( ) ) )
546+ }
543547 }
544548}
545549
You can’t perform that action at this time.
0 commit comments