From d11bd11c9ce9d65d802c95a0ecb1e180540ca568 Mon Sep 17 00:00:00 2001 From: junkmd Date: Mon, 4 Nov 2024 18:27:16 +0900 Subject: [PATCH] poc --- comtypes/_meta.py | 13 ------------- comtypes/_post_coinit/unknwn.py | 10 +--------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/comtypes/_meta.py b/comtypes/_meta.py index 60d134173..0c748c418 100644 --- a/comtypes/_meta.py +++ b/comtypes/_meta.py @@ -44,19 +44,6 @@ class _coclass_meta(type): # the coclass' _com_interfaces_ list. def __init__(self, name, bases, namespace): super().__init__(name, bases, namespace) - if bases == (object,): - # HACK: Could this conditional branch be removed since it is never reached? - # Since definition is `class CoClass(COMObject, metaclass=_coclass_meta)`, - # the `bases` parameter passed to the `_coclass_meta.__new__` would be - # `(COMObject,)`. - # Moreover, since the `COMObject` derives from `object` and does not specify - # a metaclass, `(object,)` will not be passed as the `bases` parameter - # to the `_coclass_meta.__new__`. - # The reason for this implementation might be a remnant of the differences - # in how metaclasses work between Python 3.x and Python 2.x. - # If there are no problems with the versions of Python that `comtypes` - # supports, this removal could make the process flow easier to understand. - return # XXX We should insist that a _reg_clsid_ is present. if "_reg_clsid_" in namespace: clsid = namespace["_reg_clsid_"] diff --git a/comtypes/_post_coinit/unknwn.py b/comtypes/_post_coinit/unknwn.py index 64ccd2194..2d94a8f2d 100644 --- a/comtypes/_post_coinit/unknwn.py +++ b/comtypes/_post_coinit/unknwn.py @@ -117,15 +117,7 @@ def __init__(self, name, bases, namespace): _ptr_bases = (self, POINTER(bases[0])) # The interface 'self' is used as a mixin. - # HACK: Could `type(_compointer_base)` be replaced with `_compointer_meta`? - # `type(klass)` returns its metaclass. - # Since this specification, `type(_compointer_base)` will return the - # `_compointer_meta` type as per the class definition. - # The reason for this implementation might be a remnant of the differences in - # how metaclasses work between Python 3.x and Python 2.x. - # If there are no problems with the versions of Python that `comtypes` - # supports, this replacement could make the process flow easier to understand. - p = type(_compointer_base)( + p = _compointer_meta( f"POINTER({self.__name__})", _ptr_bases, {"__com_interface__": self, "_needs_com_addref_": None},