On Wed, 10 Apr 2013 18:49:24 +0200, Tobias Rzepka <tobias.rze...@gmail.com> wrote: > Phil Thompson schrieb am 09.04.2013 15:45: >> On Fri, 05 Apr 2013 16:20:58 +0200, Tobias Rzepka >> <tobias.rze...@gmail.com> >> wrote: >>> Hello Phil, >>> >>> I have encountered some odd behavior in the QSettings if I use the same >>> ini with Python 2 and Python 3. I was able to track the problem down to >>> a entry which is a complex list with dictionaries in it (in the example >>> the ViewProfiles entry from Eric5). >>> >>> There are two solutions I've found: >>> 1. Delete the ViewProfiles entry >>> 2. Access the ini without a default parameter of the QSettings.value >> method >>> Detlev and I would like to implement the second solution because users >>> who use a old (<=5.3) and new version of Eric5 with different >>> interpreter should see merely no differences in there settings. >>> >>> The funny thing is, thats not only the default parameter of the value >>> method but also the surrounding. I've to store the settings in a class >>> (Prefs) and the second parameter has to be from another class, like in >>> the example. >>> >>> And if you uncomment the line SingleApplicationMode=false, everything is >>> fine again (but also no solution, because the next access is going to >>> fail). >>> >>> Can you tell, if it's a odd behavior of QSettings or maybe of Python? >>> >>> I've attached a ini and a little code snippet from eric5, to demonstrate >>> the behavior. The error message is the following: >>> >>> Traceback (most recent call last): >>> File "D:\Projekte\Eric5\qsettings\py2_qsettings.py", line 54, in >>> <module> >>> Prefs2.uiDefaults['SingleApplicationMode']) >>> File "C:\Python27\lib\encodings\__init__.py", line 100, in >>> search_function >>> level=0) >>> File "C:\Python27\lib\pickle.py", line 1382, in loads >>> return Unpickler(file).load() >>> File "C:\Python27\lib\pickle.py", line 858, in load >>> dispatch[key](self) >>> File "C:\Python27\lib\pickle.py", line 886, in load_proto >>> raise ValueError, "unsupported pickle protocol: %d" % proto >>> ValueError: unsupported pickle protocol: 3 >>> >>> >>> Thanks. Tobias >>> >>> By the way: If I manage to read the ini and save it again, Python 2 >>> removes the quotation marks around the ViewProfiles values. Afterwards, >>> the settings file isn't readable in Python 3... >> Have you made your example too simple? It works fine for me. >> >> Phil >> > Hello Phil, > > I've tried it now on three different machines and different Python2 / > PyQt4 versions and all of them showed the exception. > I've tried > > 1. > Win7, 64bit, Py2.7.3 64bit, PyQt4 4.9.4 > Win7, 64bit, Py2.7.4 32bit, PyQt4 4.10 > 2. > Win7, 64bit, Py2.7.3 32bit, PyQt4 4.9.5 > 3. > Win7, 32bit, Py2.7.3 32bit, PyQt4 4.9.4 > > No machine have a development environment for PyQt. All of them use the > GPL version of your installer. > Maybe that's the difference? > > *Maybe it's the way you called my script:* if I run it from command line
> (only tested with Win7, 64bit, Py2.7.4 32bit, PyQt4 4.10) like > c:\python27\python.exe py2_qsettings.py > it throws the exception, if I use execfile('py2_qsettings.py') it works > flawless! PyQt uses the default pickle protocol to handle serialising objects that it has no explicit support for. The default protocol for Python3 is incompatible with the default for Python2. I could add a pyqtSetPickleProtocol() function to QtCore to allow an application to set a compatible protocol. Phil _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt