Thanks for the reply!

On Aug 19, 2011, at 09:10 AM, Hugo Parente Lima <hugo.l...@openbossa.org> wrote:

 
The first of those bug reports is about PyQt where it is explained that everything is returned from Qt as a string, but this is only what is observed on Linux. For example, on Windows int() type is preserved as can be seen by running the script. And on OSX all types are preserved. As the example script I gave illustrates, you get different behavior depending on which platform it is executed on (for executions past the first when saved settings are restored).

On review I realize I got my impression about the autoconversion of native python types from PSEP 101 (http://www.pyside.org/docs/pseps/psep-0101.html). For example,

"PyQt's approach to dealing with QVariants will be mimicked: Python objects are automatically converted to and from QVariants wherever QVariants must be passed as arguments and when QVariants are returned."

"By supporting automatic conversion to and from QVariants, any Python object (including dicts, lists, and tuples) can be used wherever a QVariant is expected, so most programmers most of the time won't have to know or care about QVariant at all."

While I suppose that strictly speaking a programmer doesn't need to know about QVariant the significant variation in behavior between platforms (proper conversion to/from native python types versus everything becomes a string) it does mean that if the intention is to have a cross-platform application then a knowledge of the (undocumented) differences is helpful.

The documentation is also wrong. For example, it suggests the following to restore an integer value:
>>> margin = settings.value("editor/wrapMargin").toInt()
But doing so results in an error:
AttributeError: 'unicode' object has no attribute 'toInt'
That particular example would seem to have been taken from PyQt where QVariant types are returned and have a .toInt() function.
QSettings() documentation does have a section covering niggles between the platforms, but omits any mention of the variant behavior. To me it would make sense to document the differences.

Note, I started down this road after successfully converting from PyQt to PySide on Linux and then discovered that the application would fail to start on other platforms once the PySide version's settings file was stored. That particular issue had to do with how None was (or was not) preserved.
_______________________________________________
PySide mailing list
PySide@lists.pyside.org
http://lists.pyside.org/listinfo/pyside

Reply via email to