[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: QJsonDocument fails with a confusing error
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2020-06-10 14:17:45
Message-ID: cb579a4938ec66e3e08fc44f0512be9d () riverbankcomputing ! com
[Download RAW message or body]

On 10/06/2020 08:35, Anton Yablokov wrote:
> Dear developers,
> 
> Consider the following piece of code:
> 
> from PyQt5.QtCore import QJsonDocument
> 
> json = {
>     "catalog": [
>         {
>             "version": None,
>         },
>     ]}QJsonDocument(json)
> 
> Under Python 3.6+ and PyQt514+ (haven't checked other versions), it 
> results
> in the following error at the last line:
> 
> TypeError: a value has type 'list' but 'QJsonValue' is expected
> 
> QJsonDocument clearly supports lists: QJsonDocument({'a': []}) works 
> fine.
> 
> As it turns out, the None value is the reason. Although the docs
> <https://doc.qt.io/qt-5/qjsondocument.html#JsonFormat-enum> clearly 
> show
> that QJsonDocument supports null values, None is not supported in
> PyQt5: QJsonDocument({'a':
> None}) results in
> 
> TypeError: a value has type 'NoneType' but 'QJsonValue' is expected.
> 
> Is it a bug that None is not translated as null? If not, the error 
> message
> should be more informative, at least.

More an omission rather than a bug. Fixed in tonight's snapshot.

Phil
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic