Qt6: QUrl and UrlFormattingOption vs. ComponentFormattingOption
Florian Bruhin
me at the-compiler.org
Sun Nov 28 16:21:45 GMT 2021
Hi again,
On Thu, Aug 26, 2021 at 05:19:57PM +0100, Phil Thompson wrote:
>
> On 26/08/2021 16:34, Florian Bruhin wrote:
> > Hi,
> >
> > Qt's QUrl.toString() (and other methods taking QUrl.UrlFormattingOption)
> > are a bit weird, because they *also* can take
> > QUrl.ComponentFormattingOption:
> > https://doc.qt.io/qt-6/qurl.html#UrlFormattingOption-enum
> >
> > However, combining the two doesn't seem to be possible anymore with
> > PyQt6:
> >
> > >>> from PyQt6.QtCore import QUrl
> > >>> > > QUrl("https://example.org").toString(QUrl.UrlFormattingOption.RemovePassword > > | QUrl.ComponentFormattingOption.FullyEncoded)
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > TypeError: unsupported operand type(s) for |:
> > 'UrlFormattingOption' and 'ComponentFormattingOption'
> >
> > and converting won't work either:
> >
> > >>> > > QUrl("https://example.org").toString(QUrl.UrlFormattingOption.RemovePassword
> > |
> > QUrl.UrlFormattingOption(QUrl.ComponentFormattingOption.FullyEncoded))
> > ValueError: <ComponentFormattingOption.FullyEncoded: 32505856> is
> > not a valid QUrl.UrlFormattingOption
> >
> > Florian
>
> Fixed in the next PyQt6 snapshot.
After looking at this again I found another related issue: While
combining the two now works as expected, only passing a
ComponentFormattingOption fails, while working as expected with PyQt5:
$ python3 -c "from PyQt5.QtCore import QUrl; u = QUrl('https://example.org/'); print(u.toString(QUrl.ComponentFormattingOption.PrettyDecoded))"
$ python3 -c "from PyQt6.QtCore import QUrl; u = QUrl('https://example.org/'); print(u.toString(QUrl.ComponentFormattingOption.PrettyDecoded))"
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: toString(self, options: QUrl.UrlFormattingOption = QUrl.FormattingOptions(QUrl.PrettyDecoded)): argument 1 has unexpected type 'ComponentFormattingOption'
Florian
--
me at the-compiler.org | https://www.qutebrowser.org
https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20211128/b55fecf7/attachment.sig>
More information about the PyQt
mailing list