phil at riverbankcomputing.com
Thu Jul 26 13:37:38 BST 2012
On Thu, 26 Jul 2012 14:21:57 +0200, Wilbert Berendsen <wbsoft at xs4all.nl>
> Op Mon, 16 Jul 2012 12:11:11 +0100
> Phil Thompson <phil at riverbankcomputing.com> schreef:
>> On Fri, 13 Jul 2012 15:49:48 +0200, Rodolfo Zitellini
>> <xhero.gm at gmail.com> wrote:
>> > The offending code is in setup.py, when it reads the language:
>> > language = QSettings().value("language", "")
>> > print language
>> > if not language:
>> > try:
>> > language = locale.getdefaultlocale()
>> > except ValueError:
>> > pass
>> > if not language:
>> > language = "C"
>> > return language
>> > in linux, language prints None, on osx it prints QPyNullVariant. it
>> > will then evaluate False in "if not language" and then crash when it
>> > arrives in __init__.py.
>> > This used to work with qt 4.7 on osx. Just upgrading to 4.8 breaks
>> > everything.
>> > Any ideas?
>> It would suggest that there is a null QVariant stored in the settings
>> for "language". If there was no value stored then "" would be
>> returned. A workaround would therefore be to update or delete the
>> settings data either manually or with a little script.
> I'm the author of Frescobaldi.
> I was not expecting QPyNullVariant() to be returned when I specify a
> default value. Why is it that bool(the returned QPyNullVariant)
> defaults to True?
It no longer does...
> What is the best way to check for a possible QPyNullVariant to be
> returned from the QSettings().value() method? (I.e. it should also work
> on PyQt-4.7 systems).
You will have to do something that explicitly handles the different PyQt
The best thing to do would be to ensure you never write a null QVariant to
the settings in the first place.
> My code uses QSettings().value almost everywhere. I was happy with the
> simple interface, although it would be nice if the returned value would
> be forced in the type of the default value if specified.
Try the optional "type" keyword argument to QVariant.value().
Unfortunately there was a bug in the PyQt documentation builder that means
that section of the documentation that covers this is replaced by the
QSettings class reference. You can still read it in the Sphinx sources
> When I must check for more possible types to be returned, I must create
> a wrapper function for it, I guess....
More information about the PyQt