Skip to content

bug in docstring generation from DispInterfaceHead #359

@junkmd

Description

@junkmd

I discovered this in the process of investigating #347.

I was checking the proprietary .tlb file that comtypes uses for testing and the Python modules generated from it.
I saw the following definition of DTestDispServerEvents in the module generated from TestDispServer.tlb.
The docstring is not written on the line immediately below the class.

class DTestDispServerEvents(comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0.IDispatch):
    _case_insensitive_ = True
    'A custom event interface'
    _iid_ = GUID('{3B3B2A10-7FEF-4BCC-90FE-43A221162B1B}')
    _idlflags_ = []
    _methods_ = []

This causes the __doc__ attribute of DTestDispServerEvents to be assigned None.

I think this can be solved by changing the class definition that the codegenerator makes based on the typedesc.DispInterfaceHead.
This bug might be fixed by reversing the order of the lines defining the _case_insensitive_ attribute(line 948 in below) and the lines defining the docstring(line 949-951 in below).

def DispInterfaceHead(self, head):
self.generate(head.itf.base)
basename = self.type_name(head.itf.base)
self.need_GUID()
if not self.last_item_class:
print(file=self.stream)
print(file=self.stream)
self.last_item_class = True
print("class %s(%s):" % (head.itf.name, basename), file=self.stream)
print(" _case_insensitive_ = True", file=self.stream)
doc = getattr(head.itf, "doc", None)
if doc:
print(" %r" % doc, file=self.stream)

And it will need to use the _to_docstring that added in #338.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions