From b1b9810a16639e93af6b5c7e4beefce95456fcfb Mon Sep 17 00:00:00 2001 From: junkmd Date: Mon, 7 Oct 2024 22:10:24 +0900 Subject: [PATCH] Add a `HACK` comment to `_cominterface_meta.__new__`. --- comtypes/_post_coinit/unknwn.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/comtypes/_post_coinit/unknwn.py b/comtypes/_post_coinit/unknwn.py index 81b7ab97..250e2e3c 100644 --- a/comtypes/_post_coinit/unknwn.py +++ b/comtypes/_post_coinit/unknwn.py @@ -90,6 +90,16 @@ def __new__(cls, 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 + # `_compointer_meta` as per the class definition. + # This implementation might be a remnant of the differences in how metaclasses + # work between Python 3.x and Python 2.x. + # The reason for this implementation might be a remnant of the differences in + # how metaclasses function 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)( f"POINTER({self.__name__})", _ptr_bases,