[New-bugs-announce] [issue21873] Tuple comparisons with NaNs are broken

Mak Nazečić-Andrlon report at bugs.python.org
Thu Jun 26 10:23:29 CEST 2014


New submission from Mak Nazečić-Andrlon:

While searching for a way to work around the breakage of the Schwartzian transform in Python 3 (and the resulting awkwardness if you wish to use heapq or bisect, which do not yet have a key argument), I thought of the good old IEEE-754 NaN. Unfortunately, that shouldn't work since lexicographical comparisons shouldn't stop for something comparing False all the time. Nevertheless:

>>> (1, float("nan"), A()) < (1, float("nan"), A())
False
>>> (0, float("nan"), A()) < (1, float("nan"), A())
True

Instead of as in
>>> nan = float("nan")
>>> (1, nan, A()) < (1, nan, A())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: A() < A()

(As a side note, PyPy3 does not have this bug.)

----------
components: Interpreter Core
messages: 221600
nosy: Electro
priority: normal
severity: normal
status: open
title: Tuple comparisons with NaNs are broken
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21873>
_______________________________________


More information about the New-bugs-announce mailing list