aisk · GitHub

@aisk

Bug report

Bug description:

There is the document for winreg.HKEYType:

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:

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

Read the original on github.com ↗