Address boundary error on POST QHttpMultiPart

Šimon Leitgeb leitgeb.simon at gmail.com
Mon Nov 6 08:53:51 GMT 2023


Hi everyone,

I actually managed to fix it after some more digging. The issue was that
the multipart body of the request was garbage collected by Python before
the request was sent. The fix is to set the parent of the QHttpMultiPart
object to the associated QNetworkResponse before leaving the scope where
the multipart object is defined. I thought this was not necessary as I'm
not used to thinking about ownership when developing in Python.

A working example is attached for anyone that might run into similar
problems in the future.

Have a great day,
Simon

st 1. 11. 2023 v 12:47 odesílatel <colin.mcphail at mac.com> napsal:

> Hi  Šimon,
>
> On 31 Oct 2023, at 19:52, Šimon Leitgeb <leitgeb.simon at gmail.com> wrote:
>
> QHttpMultiPart
>
>
> I can confirm that your test program crashes on my system:
>
>          PyQt6 Version Information
> ╭───────────┬──────────────────────────────╮
> │ Component │           Version            │
> ├───────────┼──────────────────────────────┤
> │ Platform  │ macOS-14.1-x86_64-i386-64bit │
> │  Python   │       3.12.0 (CPython)       │
> │   PyQt6   │            6.6.0             │
> │    Qt6    │            6.6.0             │
> ╰───────────┴──────────────────────────────╯
>
> I also ran the test using the other Python Qt wrapper (PySide6) and it too
> crashed in a similar manner. This seems to imply that the problem lies with
> Qt6 itself, not PyQt6. If you can get a C++ version of your test case to
> reproduce the crash you could submit a bug report to Qt's maintainers.
>
> Sorry not to be of direct help.
>
> Regards,
> Colin McPhail
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20231106/e7ed3fa9/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: post.py
Type: text/x-python
Size: 1538 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20231106/e7ed3fa9/attachment.py>


More information about the PyQt mailing list