Skip to content

Commit

Permalink
add guard clauses for ComInterfaceHead and ComInterfaceBody.
Browse files Browse the repository at this point in the history
  • Loading branch information
junkmd committed Apr 15, 2024
1 parent b24c2c4 commit 63f38aa
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions comtypes/tools/codegenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,16 @@ def generate(self, item):
self.done.add(item) # to avoid infinite recursion.
self.ComInterface(item)
return
if isinstance(item, typedesc.ComInterfaceHead):
if self._is_known_interface(item.itf):
return
self.ComInterfaceHead(item)
return
if isinstance(item, typedesc.ComInterfaceBody):
if self._is_known_interface(item.itf):
return
self.ComInterfaceBody(item)
return
if isinstance(item, typedesc.StructureHead):
name = getattr(item.struct, "name", None)
else:
Expand Down Expand Up @@ -1101,8 +1111,6 @@ def _is_enuminterface(self, itf: typedesc.ComInterface) -> bool:
return True

def ComInterfaceHead(self, head: typedesc.ComInterfaceHead) -> None:
if self._is_known_interface(head.itf):
return
base = head.itf.base
if head.itf.base is None:
# we don't beed to generate IUnknown
Expand Down

0 comments on commit 63f38aa

Please sign in to comment.