[PyQt] Possible small bug in docstring generation
Phil Thompson
phil at riverbankcomputing.com
Fri Jun 16 13:06:52 BST 2017
On 15 Jun 2017, at 7:58 pm, Shaheed Haque <srhaque at theiet.org> wrote:
>
> Attached is a patch that converts this SIP:
>
> ===========
> virtual void
> openDialogIncidenceCreated(Akonadi::ITIPHandlerDialogDelegate::Recipient
> recipient, const QString &question,
> Akonadi::ITIPHandlerDialogDelegate::Action action =
> Akonadi::ITIPHandlerDialogDelegate::ActionAsk, const KGuiItem
> &buttonYes = KGuiItem(i18nc("@action:button dialog positive
> answer","Send Email")), const KGuiItem &buttonNo =
> KGuiItem(i18nc("@action:button dialog negative answer","Do Not
> Send")));
> ============
>
> into this C++ code:
>
> ============
> PyDoc_STRVAR(doc_Akonadi_ITIPHandlerDialogDelegate_openDialogIncidenceCreated,
> "openDialogIncidenceCreated(self,
> Akonadi.ITIPHandlerDialogDelegate.Recipient, str,
> Akonadi.ITIPHandlerDialogDelegate.Action =
> Akonadi.ITIPHandlerDialogDelegate.ActionAsk, KGuiItem =
> KGuiItem(i18nc(\"@action:button dialog positive answer\",\"Send
> Email\")), KGuiItem = KGuiItem(i18nc(\"@action:button dialog negative
> answer\",\"Do Not Send\")))");
> .
> .
> .
> {
> ::Akonadi::ITIPHandlerDialogDelegate::Recipient a0;
> const ::QString* a1;
> int a1State = 0;
> ::Akonadi::ITIPHandlerDialogDelegate::Action a2 =
> Akonadi::ITIPHandlerDialogDelegate::ActionAsk;
> const ::KGuiItem& a3def = KGuiItem(i18nc("@action:button
> dialog positive answer","Send Email"));
> const ::KGuiItem* a3 = &a3def;
> const ::KGuiItem& a4def = KGuiItem(i18nc("@action:button
> dialog negative answer","Do Not Send"));
> ============
>
> As you can see, the PyDoc_STRVAR has the quotes escaped, but a3def and
> a4def do not. Now, the patch as-is is slightly overkill in the sense
> that it introduces a %q format code for prcode, which I expected would
> be needed for cases like:
>
> ..., QString bar = "worst \"stri\\ng ever", ...
>
> to generate:
>
> ..., QString bar = \"worst \\\"stri\\\\ng ever\", ...
>
> However, it seems that SIP's lexer does not like the escapes. I did
> not feel comfortable patching that here and now, so as I say, that
> make the %q arguably overkill.
>
> Please consider the patch, which is against sip-4.19.3.dev1706101519,
> with or without the %q stuff.
Can you try tonight's snapshot? Hopefully the lexer now supports escape characters properly.
Phil
More information about the PyQt
mailing list