Skip to content

Commit

Permalink
poc
Browse files Browse the repository at this point in the history
  • Loading branch information
junkmd committed Nov 4, 2024
1 parent 8e0af2c commit d11bd11
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
13 changes: 0 additions & 13 deletions comtypes/_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_"]
Expand Down
10 changes: 1 addition & 9 deletions comtypes/_post_coinit/unknwn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit d11bd11

Please sign in to comment.