[PyQt] QSettings with different Python versions

Tobias Rzepka tobias.rzepka at gmail.com
Fri Apr 5 15:20:58 BST 2013


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...
-------------- next part --------------
[Debugger]
PythonInterpreter=C:\\Python27\\python.exe

[PluginManager]
DownloadPath=C:\\Users\\Tobias\\_eric5\\Downloads
InactivePlugins=@Invalid()

[Symbols]
CurrentTable=1
Top=0

[UI]
ToolbarManagerState=@ByteArray(\xff\xff\0\0\xfe\xfe\0\x11\0\0\0\x14MultiProjectToolbar\0\0\x6\0\0\0\x12multi_project_new\0\0\0\0\x13multi_project_open\0\0\0\0\x14multi_project_close\0\0\0\0\x1\0\0\0\0\x13multi_project_save\0\0\0\0\x16multi_project_save_as\0\0\0\0\xfProjectToolbar\0\0\x6\0\0\0\fproject_new\0\0\0\0\rproject_open\0\0\0\0\xeproject_close\0\0\0\0\x1\0\0\0\0\rproject_save\0\0\0\0\x10project_save_as\0\0\0\0\rStartToolbar\0\0\b\0\0\0\x13\x64\x62g_restart_script\0\0\0\0\x10\x64\x62g_stop_script\0\0\0\0\x1\0\0\0\0\xf\x64\x62g_run_script\0\0\0\0\x10\x64\x62g_run_project\0\0\0\0\x1\0\0\0\0\x11\x64\x62g_debug_script\0\0\0\0\x12\x64\x62g_debug_project\0\0\0\0\fHelpToolbar\0\0\x1\0\0\0\nwhatsThis\0\0\0\0\fEditToolbar\0\0\xe\0\0\0\rvm_edit_undo\0\0\0\0\rvm_edit_redo\0\0\0\0\x1\0\0\0\0\fvm_edit_cut\0\0\0\0\rvm_edit_copy\0\0\0\0\xevm_edit_paste\0\0\0\0\xevm_edit_clear\0\0\0\0\x1\0\0\0\0\xfvm_edit_indent\0\0\0\0\x11vm_edit_unindent\0\0\0\0\x1\0\0\0\0\x10vm_edit_comment\0\0\0\0\x12vm_edit_uncomment\0\0\0\0\x17vm_edit_toggle_comment\0\0\0\0\x10SettingsToolbar\0\0\x5\0\0\0\fpreferences\0\0\0\0\xeview_profiles\0\0\0\0\x13\x63onfigure_toolbars\0\0\0\0\x13keyboard_shortcuts\0\0\0\0\x14show_external_tools\0\0\0\0\xeSearchToolbar\0\0\f\0\0\0\nvm_search\0\0\0\0\xfvm_search_next\0\0\0\0\x13vm_search_previous\0\0\0\0\x14vm_search_word_next\0\0\0\0\x18vm_search_word_previous\0\0\0\0\x1\0\0\0\0\x18vm_clear_search_markers\0\0\0\0\x1\0\0\0\0\x13vm_search_in_files\0\0\0\0\x18vm_search_in_open_files\0\0\0\0\x1\0\0\0\0\"vm_search_goto_last_edit_location\0\0\0\0\x11\x42ookmarksToolbar\0\0\xe\0\0\0\x13vm_bookmark_toggle\0\0\0\0\x11vm_bookmark_next\0\0\0\0\x15vm_bookmark_previous\0\0\0\0\x1\0\0\0\0\x14vm_syntaxerror_goto\0\0\0\0\x1\0\0\0\0\x10vm_warning_next\0\0\0\0\x14vm_warning_previous\0\0\0\0\x1\0\0\0\0\rvm_task_next\0\0\0\0\x11vm_task_previous\0\0\0\0\x1\0\0\0\0\xfvm_change_next\0\0\0\0\x13vm_change_previous\0\0\0\0\xfPluginsToolbar\0\0\x5\0\0\0\rplugin_infos\0\0\0\0\xfplugin_install\0\0\0\0\x11plugin_deinstall\0\0\0\0\x1\0\0\0\0\x12plugin_repository\0\0\0\0\x10UnittestToolbar\0\0\a\0\0\0\tunittest\0\0\0\0\x1\0\0\0\0\x11unittest_restart\0\0\0\0\x16unittest_rerun_failed\0\0\0\0\x1\0\0\0\0\x10unittest_script\0\0\0\0\x11unittest_project\0\0\0\0\rDebugToolbar\0\0\v\0\0\0\rdbg_continue\0\0\0\0\x17\x64\x62g_continue_to_cursor\0\0\0\0\x10\x64\x62g_single_step\0\0\0\0\xe\x64\x62g_step_over\0\0\0\0\rdbg_step_out\0\0\0\0\tdbg_stop\0\0\0\0\x1\0\0\0\0\x16\x64\x62g_toggle_breakpoint\0\0\0\0\x14\x64\x62g_edit_breakpoint\0\0\0\0\x14\x64\x62g_next_breakpoint\0\0\0\0\x18\x64\x62g_previous_breakpoint\0\0\0\0\x13QuicksearchToolbar\0\0\x4\0\0\0\x18vm_quickfindtext_action\0\0\0\0\xfvm_quicksearch\0\0\0\0\x19vm_quicksearch_backwards\0\0\0\0\x16vm_quicksearch_extend\0\0\0\0\fFileToolbar\0\0\v\0\0\0\vnew_window\0\0\0\0\x1\0\0\0\0\fvm_file_new\0\0\0\0\rvm_file_open\0\0\0\0\xevm_file_close\0\0\0\0\x1\0\0\0\0\rvm_file_save\0\0\0\0\x10vm_file_save_as\0\0\0\0\x11vm_file_save_all\0\0\0\0\x1\0\0\0\0\x5quit\0\0\0\0\x10ProfilesToolbar\0\0\x2\0\0\0\redit_profile\0\0\0\0\xe\x64\x65\x62ug_profile\0\0\0\0\rToolsToolbar\0\0\xf\0\0\0\rqt_designer4\0\0\0\0\rqt_linguist4\0\0\0\0\rui_previewer\0\0\0\0\rtr_previewer\0\0\0\0\x1\0\0\0\0\vdiff_files\0\0\0\0\xe\x63ompare_files\0\0\0\0\x1\0\0\0\0\fsql_browser\0\0\0\0\x1\0\0\0\0\fmini_editor\0\0\0\0\ficon_editor\0\0\0\0\tsnapshot\0\0\0\0\x1\0\0\0\0\fweb_browser\0\0\0\0\fViewToolbar\0\0\x6\0\0\0\x10vm_view_zoom_in\0\0\0\0\x11vm_view_zoom_out\0\0\0\0\x13vm_view_zoom_reset\0\0\0\0\rvm_view_zoom\0\0\0\0\x1\0\0\0\0\vvm_preview\0\0\0\0\x10SpellingToolbar\0\0\x2\0\0\0\x17vm_spelling_spellcheck\0\0\0\0\x1bvm_spelling_autospellcheck\0\xfd\xfd\0\0)
ViewProfiles2="{\"edit\": [\"AAAA/wAAAAD9AAAAAAAAB2EAAAOuAAAAAQAAAAIAAAAIAAAACPwAAAACAAAAAQAAAAIAAAAeAFMAZQB0AHQAaQBuAGcAcwBUAG8AbwBsAGIAYQByAwAAAAD/////AAAAAAAAAAAAAAAYAFQAbwBvAGwAcwBUAG8AbwBsAGIAYQByAwAAAIT/////AAAAAAAAAAAAAAACAAAADwAAABYARgBpAGwAZQBUAG8AbwBsAGIAYQByAQAAAAD/////AAAAAAAAAAAAAAAWAEUAZABpAHQAVABvAG8AbABiAGEAcgEAAAD2/////wAAAAAAAAAAAAAAGgBTAGUAYQByAGMAaABUAG8AbwBsAGIAYQByAAAAAAD/////AAAAAAAAAAAAAAAkAFEAdQBpAGMAawBzAGUAYQByAGMAaABUAG8AbwBsAGIAYQByAAAAAAD/////AAAAAAAAAAAAAAAWAFYAaQBlAHcAVABvAG8AbABiAGEAcgAAAAAA/////wAAAAAAAAAAAAAAGABTAHQAYQByAHQAVABvAG8AbABiAGEAcgEAAAI9/////wAAAAAAAAAAAAAAGABEAGUAYgB1AGcAVABvAG8AbABiAGEAcgAAAAAA/////wAAAAAAAAAAAAAAJgBNAHUAbAB0AGkAUAByAG8AagBlAGMAdABUAG8AbwBsAGIAYQByAAAAAAD/////AAAAAAAAAAAAAAAcAFAAcgBvAGoAZQBjAHQAVABvAG8AbABiAGEAcgEAAAL3/////wAAAAAAAAAAAAAAFgBIAGUAbABwAFQAbwBvAGwAYgBhAHIAAAAAAP////8AAAAAAAAAAAAAACAAQgBvAG8AawBtAGEAcgBrAHMAVABvAG8AbABiAGEAcgEAAAOQ/////wAAAAAAAAAAAAAAHgBTAHAAZQBsAGwAaQBuAGcAVABvAG8AbABiAGEAcgAAAAAA/////wAAAAAAAAAAAAAAHgBVAG4AaQB0AHQAZQBzAHQAVABvAG8AbABiAGEAcgAAAAAA/////wAAAAAAAAAAAAAAHgBQAHIAbwBmAGkAbABlAHMAVABvAG8AbABiAGEAcgEAAATC/////wAAAAAAAAAAAAAAHABQAGwAdQBnAGkAbgBzAFQAbwBvAGwAYgBhAHIAAAAAAP////8AAAAAAAAAAA==\", [true, true, true], [\"AAAA/wAAAAAAAAACAAABMwAABikAAAAABQEAAAAB\", \"AAAA/wAAAAAAAAACAAADFAAAAJUAAAAABQEAAAAC\", \"AAEAAAABpQAAA7gBC///AAIBMwYpAA==\", \"AAEAAAAB2gAAAkwAkv//AAIDFACVAA==\", \"AAAA/wAAAAAAAAACAAAE8wAAATEAAAAABQEAAAAB\", \"AAEAAAABWAAAA7gA6f//AAIE8wExAA==\"]], \"debug\": [\"AAAA/wAAAAD9AAAAAAAABOEAAAO4AAAAAQAAAAIAAAAIAAAACPwAAAACAAAAAQAAAAIAAAAeAFMAZQB0AHQAaQBuAGcAcwBUAG8AbwBsAGIAYQByAwAAAAD/////AAAAAAAAAAAAAAAYAFQAbwBvAGwAcwBUAG8AbwBsAGIAYQByAwAAAIT/////AAAAAAAAAAAAAAACAAAADwAAABYARgBpAGwAZQBUAG8AbwBsAGIAYQByAQAAAAD/////AAAAAAAAAAAAAAAWAEUAZABpAHQAVABvAG8AbABiAGEAcgEAAAD2/////wAAAAAAAAAAAAAAGgBTAGUAYQByAGMAaABUAG8AbwBsAGIAYQByAAAAAAD/////AAAAAAAAAAAAAAAkAFEAdQBpAGMAawBzAGUAYQByAGMAaABUAG8AbwBsAGIAYQByAAAAAAD/////AAAAAAAAAAAAAAAWAFYAaQBlAHcAVABvAG8AbABiAGEAcgAAAAAA/////wAAAAAAAAAAAAAAGABTAHQAYQByAHQAVABvAG8AbABiAGEAcgEAAAI9/////wAAAAAAAAAAAAAAGABEAGUAYgB1AGcAVABvAG8AbABiAGEAcgEAAAL3/////wAAAAAAAAAAAAAAJgBNAHUAbAB0AGkAUAByAG8AagBlAGMAdABUAG8AbwBsAGIAYQByAAAAAAD/////AAAAAAAAAAAAAAAcAFAAcgBvAGoAZQBjAHQAVABvAG8AbABiAGEAcgAAAAL3/////wAAAAAAAAAAAAAAFgBIAGUAbABwAFQAbwBvAGwAYgBhAHIAAAAAAP////8AAAAAAAAAAAAAACAAQgBvAG8AawBtAGEAcgBrAHMAVABvAG8AbABiAGEAcgEAAAQX/////wAAAAAAAAAAAAAAHgBTAHAAZQBsAGwAaQBuAGcAVABvAG8AbABiAGEAcgAAAAAA/////wAAAAAAAAAAAAAAHgBVAG4AaQB0AHQAZQBzAHQAVABvAG8AbABiAGEAcgAAAAAA/////wAAAAAAAAAAAAAAHgBQAHIAbwBmAGkAbABlAHMAVABvAG8AbABiAGEAcgEAAATN/////wAAAAAAAAAAAAAAHABQAGwAdQBnAGkAbgBzAFQAbwBvAGwAYgBhAHIAAAAAAP////8AAAAAAAAAAA==\", [false, true, true], [\"AAAA/wAAAAAAAAACAAABHgAAAjAAAAAABQEAAAAB\", \"AAAA/wAAAAAAAAACAAAAhAAAANgAAAAABQEAAAAC\", \"AAEAAAABpQAAA7gBC///AAIBpQM3AA==\", \"AAEAAAAB2gAAAkwAkv//AAIBZwJMAA==\", \"AAAA/wAAAAAAAAACAAABAAAAATAAAAAABQEAAAAB\", \"AAEAAAABWAAAA7gA6f//AAIB2gFYAA==\"]]}"
SingleApplicationMode=false
ShowSplash=true
OpenOnStartup=4
PerformVersionCheck=4
CheckErrorLog=true
ViewProfiles="@Variant(\0\0\0\b\0\0\0\x2\0\0\0\b\0\x65\0\x64\0i\0t\0\0\0\t\0\0\0\a\0\0\0\t\0\0\0\f\0\0\0\x1\x1\0\0\0\x1\0\0\0\0\x1\0\0\0\0\x1\x1\0\0\0\x1\x1\0\0\0\x1\x1\0\0\0\x1\x1\0\0\0\x1\x1\0\0\0\x1\x1\0\0\0\x1\x1\0\0\0\x1\x1\0\0\0\x1\x1\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\t\0\0\0\f\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x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0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\t\0\0\0\x3\0\0\0\x1\0\0\0\0\x1\x1\0\0\0\x1\x1\0\0\0\t\0\0\0\x6\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\a\x80\x3\x43\0q\0.)"

[IRC]
Identities\0default\Ident=Tobias
Identities\0default\RealName=eric IDE chat
Identities\0default\NickNames=Tobias, Tobias_, Tobias__
Identities\0default\ServiceName=
Identities\0default\Password=
Identities\0default\QuitMessage=IRC Client der eric5 IDE
Identities\0default\PartMessage=IRC Client der eric5 IDE
Identities\0default\RememberAwayPosition=true
Identities\0default\AwayMessage=Bin bis auf weiteres weg.
Networks\Freenode%20%28SSL%29\Identity=0default
Networks\Freenode%20%28SSL%29\AutoConnect=false
Networks\Freenode%20%28SSL%29\Server\Name=chat.freenode.net
Networks\Freenode%20%28SSL%29\Server\Port=6697
Networks\Freenode%20%28SSL%29\Server\SSL=true
Networks\Freenode%20%28SSL%29\Server\Password=
Networks\Freenode%20%28SSL%29\Channels\%23eric-ide\Key=
Networks\Freenode%20%28SSL%29\Channels\%23eric-ide\AutoJoin=false
Networks\Freenode\Identity=0default
Networks\Freenode\AutoConnect=false
Networks\Freenode\Server\Name=chat.freenode.net
Networks\Freenode\Server\Port=6667
Networks\Freenode\Server\SSL=false
Networks\Freenode\Server\Password=
Networks\Freenode\Channels\%23eric-ide\Key=
Networks\Freenode\Channels\%23eric-ide\AutoJoin=false

[%General]
Configured=true

[MultiProject]
Workspace=D:/Projekte/Eric5

[Bookmarked]
Sources=@Invalid()

[Shell]
Histories\Python3=@Invalid()
Histories\Python=@Invalid()

[DebugInfo]
ArgumentsHistory=@Variant(\0\0\0\t\0\0\0\x1\0\0\0\n\0\0\0\0)
WorkingDirectoryHistory=@Variant(\0\0\0\t\0\0\0\x1\0\0\0\n\0\0\0\0)
EnvironmentHistory=@Variant(\0\0\0\t\0\0\0\x1\0\0\0\n\0\0\0\0)
Exceptions=@Invalid()
IgnoredExceptions=@Invalid()
ReportExceptions=true
AutoClearShell=true
TracePython=false
AutoContinue=true
ForkAutomatically=false
ForkIntoChild=false

[Geometry]
MainMaximized=true
MainGeometry=@ByteArray(\x1\xd9\xd0\xcb\0\x1\0\0\0\0\x1\x38\0\0\0\t\0\0\x6G\0\0\x4.\0\0\x1@\0\0\0'\0\0\x6?\0\0\x4&\0\0\0\0\0\0)

[BrowserModel]
ToplevelDirs=C:\\Users\\Tobias, C:\\, D:\\, E:\\, F:\\, H:\\, W:\\, X:\\

[Toolgroups]
Groups=0
Current%20Group=-1

[User]
UseSystemEmailClient=false

-------------- next part --------------
# coding: utf-8

import sip
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)
sip.setapi('QTextStream',  2)

import sys
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QSettings, QByteArray


class Prefs2(object):
    """
    A class to hold all configuration items for the application.
    """
    # defaults for the UI settings
    uiDefaults = {
        "SingleApplicationMode": False,
    }


class E5Application(QApplication):
    """
    Eric application class with an object registry.
    """
    def __init__(self, argv):
        """
        Constructor
        
        @param argv command line arguments
        """
        super(E5Application, self).__init__(argv)

class Prefs(object):
    pass

app = E5Application(sys.argv)

#Prefs.settings = QSettings(
#    QSettings.IniFormat, QSettings.UserScope,
#    settingsNameOrganization, settingsNameGlobal)
Prefs.settings = QSettings('eric5.ini', 
    QSettings.IniFormat)

print type(Prefs2.uiDefaults['SingleApplicationMode'])

# Avoid nasty behavior of QSettings in combination with Py2:
#Prefs.settings.value("UI/SingleApplicationMode",  False)                       # <- uncomment to avoid the error in Python2

print Prefs.settings.value("UI/SingleApplicationMode", 
            Prefs2.uiDefaults['SingleApplicationMode'])


try:
    input('ok:')
except:
    pass



More information about the PyQt mailing list