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

Closed
junkmd opened this issue Feb 8, 2024 · 0 comments · Fixed by #639
Closed

Remove remaining __cmp__ in comtypes #512

junkmd opened this issue Feb 8, 2024 · 0 comments · Fixed by #639
Labels
good first issue Good for newcomers
Milestone

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.

@junkmd junkmd added the good first issue Good for newcomers label Feb 8, 2024
This was referenced Oct 11, 2024
@junkmd junkmd linked a pull request Oct 11, 2024 that will close this issue
@junkmd junkmd added this to the 1.4.8 milestone Oct 12, 2024
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

Successfully merging a pull request may close this issue.

1 participant