comtypes
comtypes copied to clipboard
SyntaxError on parsing some of the applications docstrings
com.CreateObject('Visio.Application') returns SyntaxError starting from 1.1.13:
File "xxxxxxxxx\.tox\py39\lib\site-packages\comtypes\gen\_00021A98_0000_0000_C000_000000000046_0_4_16.py", line 20214
"""A running instance of Visio. ProgId: "Visio.Application""""
SyntaxError: EOL while scanning string literal
Very likely this issue might also reproduce for some other applications that uses the same formatting of docstrings. Also, for a comparison, here's how the same line looks on 1.1.11:
'A running instance of Visio. ProgId: "Visio.Application"'
Perhaps the causes are these.
https://github.com/enthought/comtypes/blob/096bfde508bc32466e3fac18790fc93bdaa3cc37/comtypes/tools/codegenerator.py#L660-L661 https://github.com/enthought/comtypes/blob/096bfde508bc32466e3fac18790fc93bdaa3cc37/comtypes/tools/codegenerator.py#L724-L725 https://github.com/enthought/comtypes/blob/096bfde508bc32466e3fac18790fc93bdaa3cc37/comtypes/tools/codegenerator.py#L801-L802
If only changing them to single quotes as before, it might also cause a
SyntaxError
by the source containing specific letters, like '
or \
.
A better escaping method is needed.
@pshv
Please try this (replace .../comtypes/tools/codegenerator.py
).
https://github.com/junkmd/comtypes/blob/fe273542dd878d54ea58add6ccd4935951f9ad9d/comtypes/tools/codegenerator.py
I don't have Visio
in my environment, so please try if it works in yours.
@junkmd works well for me with patched codegenerator you provided, thanks!
To solve this problem, I PRed #338.
In addition to the previous change, the indentation is also handled within the function.
@pshv 1.1.14 is out. Please try.
Works well on 1.1.14, closing the issue. Thanks @junkmd @vasily-v-ryabov