New GitHub issue #92313 from facelessuser:<br>
<hr>
<pre>
<!--
If you're new to Python and you're not sure whether what you're experiencing is a bug, the CPython issue tracker is not
the right place to seek help. Consider the following options instead:
- reading the Python tutorial: https://docs.python.org/3/tutorial/
- posting in the "Users" category on discuss.python.org: https://discuss.python.org/c/users/7
- emailing the Python-list mailing list: https://mail.python.org/mailman/listinfo/python-list
- searching our issue tracker (https://github.com/python/cpython/issues) to see if
your problem has already been reported
-->
**Bug report**
Normally, NaN will evaluate as `False` when compared against each other, but there is a case where this breaks down. The NaN values have to be the same instance, and then they have to be wrapped in a sequence. In this very specific case, the two NaN values will actually be compared as equal.
```py
>>> a = float('nan')
>>> b = a
>>> a == b
False
>>> [a] == [b]
True
```
As to exactly why this occurs, I am uncertain. The same scenario does not evaluate `True` if the Nan value is of two separate instances:
```py
>>> a = float('nan')
>>> b = float('nan')
>>> a == b
False
>>> [a] == [b]
False
```
**Your environment**
<!-- Include as many relevant details as possible about the environment you experienced the bug in -->
- CPython versions tested on: Python 3.10.4
- Operating system and architecture: macOS Montery 12.3.1
I should note that I had this bug in CI running on other systems and Python versions as well, it seems to be a quirk that has existed through multiple Python versions for at least as far back as Python 3.6, but likey longer than that.
<!--
You can freely edit this text. Remove any lines you believe are unnecessary.
-->
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/92313">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>