Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove remaining __cmp__ in comtypes #512

Open
junkmd opened this issue Feb 8, 2024 · 0 comments
Open

Remove remaining __cmp__ in comtypes #512

junkmd opened this issue Feb 8, 2024 · 0 comments
Labels
good first issue Good for newcomers

Comments

@junkmd
Copy link
Collaborator

junkmd commented Feb 8, 2024

In Python3,

The cmp() function should be treated as gone, and the __cmp__() special method is no longer supported.
https://docs.python.org/3/whatsnew/3.0.html#ordering-comparisons

However, they are still contained in comtypes.

def __cmp__(self, other):
if not isinstance(other, Dispatch):
return 1
return cmp(self._comobj, other._comobj)

def __cmp__(self, other):
if isinstance(other, GUID):
return cmp(binary(self), binary(other))
return -1

def __cmp__(self, other):
"""Compare pointers to COM interfaces."""
# COM identity rule
#
# XXX To compare COM interface pointers, should we
# automatically QueryInterface for IUnknown on both items, and
# compare the pointer values?
if not isinstance(other, _compointer_base):
return 1
# get the value property of the c_void_p baseclass, this is the pointer value
return cmp(
super(_compointer_base, self).value, super(_compointer_base, other).value
)

Remove these dead code and modernize the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant