This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Document pointer comparison in PyObject_RichCompareBool()
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: rhettinger, tamuhey
Priority: normal Keywords: patch

Created on 2020-06-20 09:20 by tamuhey, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 20999 closed rhettinger, 2020-06-20 09:59
Messages (4)
msg371927 - (view) Author: tamuhey (tamuhey) Date: 2020-06-20 09:20
Applying PyObject_RichCompareBool to two `nan`s can be true if the two nans are same object, i.e.

```
a = float("nan")
PyObject_RichCompareBool(a, a, Py_EQ) // True
```

I read the document (https://docs.python.org/3/c-api/object.html?highlight=pyobject_richcomparebool#c.PyObject_RichCompareBool) and understood it is intended, but there should be gentle comment to tell users this behaviour.
msg371928 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-06-20 09:40
Thanks for the report. I'll add a note to the C API docs.
msg371930 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-06-20 10:13
Hmm, I missed it.  There is already a note in the link you provided"

"""Note If o1 and o2 are the same object, PyObject_RichCompareBool() will always return 1 for Py_EQ and 0 for Py_NE."""
msg371931 - (view) Author: tamuhey (tamuhey) Date: 2020-06-20 10:28
> Hmm, I missed it.  There is already a note in the link you provided

I've read the comment before posting this issue.
But I think there should be the following info:

1. example (float("nan"))
2. the result is inconsistent with PyObject_RichCompare
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85221
2020-06-20 10:28:45tamuheysetmessages: + msg371931
2020-06-20 10:13:40rhettingersetstatus: open -> closed
resolution: out of date
messages: + msg371930

stage: patch review -> resolved
2020-06-20 09:59:26rhettingersetkeywords: + patch
stage: patch review
pull_requests: + pull_request20174
2020-06-20 09:54:05rhettingersettitle: PyObject_RichCompareBool(nan, nan, eq) can be True -> Document pointer comparison in PyObject_RichCompareBool()
2020-06-20 09:40:48rhettingersetversions: - Python 3.5, Python 3.6, Python 3.7
nosy: + rhettinger

messages: + msg371928

assignee: rhettinger
components: + Documentation, - C API
2020-06-20 09:20:57tamuheycreate