-
-
Notifications
You must be signed in to change notification settings - Fork 104
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
Whether it’s a remnant of Python 2.x or a legacy from the early stages of this project, the metaclass is directly accessible as shown below, it still retrieves the metaclass indirectly using type.
comtypes/comtypes/_post_coinit/unknwn.py
Lines 112 to 126 in d80810b
| _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)( | |
| f"POINTER({self.__name__})", | |
| _ptr_bases, | |
| {"__com_interface__": self, "_needs_com_addref_": None}, |
If it can be confirmed that there are no problems, replacing them would improve the readability of the codebase.
_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},Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers