-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Open
Labels
OS-windowsextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
There is the document for winreg.HKEYType:
cpython/Doc/library/winreg.rst
Lines 774 to 775 in 81cec22
| The object also support comparison semantics, so handle objects will compare | |
| true if they both reference the same underlying Windows handle value. |
But the winreg.HKEYType don't have a custom compare implementation, so it will be compared by id.
And there is a compare function in the codebase, which actually is a dead code, and still compared by id:
Lines 184 to 191 in 81cec22
| static int | |
| PyHKEY_compareFunc(PyObject *ob1, PyObject *ob2) | |
| { | |
| PyHKEYObject *pyhkey1 = (PyHKEYObject *)ob1; | |
| PyHKEYObject *pyhkey2 = (PyHKEYObject *)ob2; | |
| return pyhkey1 == pyhkey2 ? 0 : | |
| (pyhkey1 < pyhkey2 ? -1 : 1); | |
| } |
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
- gh-140826: Remove the wrong documents about comparison behavior on winreg.HKEYType #140840
- gh-140826: Compare winreg.HKEYType by the internal handle value #140843
- [3.14] gh-140826 Remove the wrong documents about comparison behavior on winreg.HKEYType #140999
- [3.13] gh-140826 Remove the wrong documents about comparison behavior on winreg.HKEYType (GH-140999) #141003
- gh-140826: Update winreg's docstring #141050
Metadata
Metadata
Assignees
Labels
OS-windowsextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error