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

Improve patching classes in _compointer_meta. #624

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions comtypes/_post_coinit/unknwn.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,20 @@ def __new__(cls, name, bases, namespace):
{"__com_interface__": new_cls, "_needs_com_addref_": None},
)

from ctypes import _pointer_type_cache
from ctypes import _pointer_type_cache # type: ignore

_pointer_type_cache[new_cls] = p

if new_cls._case_insensitive_:
new_cls._patch_to_ptr_type(p, True)
else:
new_cls._patch_to_ptr_type(p, False)

return new_cls

@staticmethod
def _patch_to_ptr_type(p, case_insensitive) -> None:
if case_insensitive:

@patcher.Patch(p)
class CaseInsensitive(object):
Expand Down Expand Up @@ -155,8 +164,6 @@ def __setitem__(self, index, value):

CopyComPointer(value, self)

return new_cls

def __setattr__(self, name, value):
if name == "_methods_":
# XXX I'm no longer sure why the code generator generates
Expand Down