--- a/eric6/Preferences/__init__.py Sun May 31 17:26:46 2020 +0200 +++ b/eric6/Preferences/__init__.py Sat Jul 04 11:45:34 2020 +0200 @@ -17,6 +17,7 @@ """ +import ast import os import fnmatch import shutil @@ -81,12 +82,8 @@ "SuppressClientExit": False, "BreakAlways": False, "ShowExceptionInShell": True, - "Python2VirtualEnv": "", "Python3VirtualEnv": "", "RubyInterpreter": "", - "DebugClientType": "standard", - # supported "standard", "custom" - "DebugClient": "", "DebugClientType3": "standard", # supported "standard", "custom" "DebugClient3": "", @@ -108,8 +105,6 @@ "BgColorNew": QColor("#28FFEEAA"), "BgColorChanged": QColor("#2870FF66"), "AllowedHosts": ["127.0.0.1", "::1%0"], - # space separated list of Python2 extensions - "PythonExtensions": ".py2 .pyw2 .ptl", # space separated list of Python3 extensions "Python3Extensions": ".py .pyw .py3 .pyw3" } @@ -469,7 +464,7 @@ "DefaultEncoding": "utf-8", "DefaultOpenFilter": QCoreApplication.translate( - 'Lexers', 'Python Files (*.py *.py2 *.py3)'), + 'Lexers', 'Python Files (*.py *.py3)'), "DefaultSaveFilter": QCoreApplication.translate( 'Lexers', "Python3 Files (*.py)"), "AdditionalOpenFilters": [], @@ -805,23 +800,6 @@ # defaults for the project browser flags settings projectBrowserFlagsDefaults = { - # deprecated - "Qt4": ( - SourcesBrowserFlag | - FormsBrowserFlag | - ResourcesBrowserFlag | - TranslationsBrowserFlag | - InterfacesBrowserFlag | - OthersBrowserFlag | - ProtocolsBrowserFlag), - # deprecated - "Qt4C": ( - SourcesBrowserFlag | - ResourcesBrowserFlag | - TranslationsBrowserFlag | - InterfacesBrowserFlag | - OthersBrowserFlag | - ProtocolsBrowserFlag), "PyQt5": ( SourcesBrowserFlag | FormsBrowserFlag | @@ -855,21 +833,6 @@ InterfacesBrowserFlag | OthersBrowserFlag | ProtocolsBrowserFlag), - "PySide": ( - SourcesBrowserFlag | - FormsBrowserFlag | - ResourcesBrowserFlag | - TranslationsBrowserFlag | - InterfacesBrowserFlag | - OthersBrowserFlag | - ProtocolsBrowserFlag), - "PySideC": ( - SourcesBrowserFlag | - ResourcesBrowserFlag | - TranslationsBrowserFlag | - InterfacesBrowserFlag | - OthersBrowserFlag | - ProtocolsBrowserFlag), "PySide2": ( SourcesBrowserFlag | FormsBrowserFlag | @@ -903,12 +866,8 @@ helpDefaults = { "CustomViewer": "", "PythonDocDir": "", - "Python2DocDir": "", - "Qt4DocDir": "", "Qt5DocDir": "", - "PyQt4DocDir": "", "PyQt5DocDir": "", - "PySideDocDir": "", "PySide2DocDir": "", "EricDocDir": "", } @@ -1619,7 +1578,6 @@ # backward compatibility fot Qt < 5.10 pass - # Avoid nasty behavior of QSettings in combination with Py2 Prefs.settings.value("UI/SingleApplicationMode") @@ -1712,9 +1670,9 @@ @param prefClass preferences class used as the storage area @return a tuple defining the variables filter """ - localsFilter = eval(prefClass.settings.value( + localsFilter = ast.literal_eval(prefClass.settings.value( "Variables/LocalsFilter", prefClass.varDefaults["LocalsFilter"])) - globalsFilter = eval(prefClass.settings.value( + globalsFilter = ast.literal_eval(prefClass.settings.value( "Variables/GlobalsFilter", prefClass.varDefaults["GlobalsFilter"])) return (localsFilter, globalsFilter) @@ -1760,10 +1718,8 @@ "Debugger/" + key, prefClass.debuggerDefaults[key])) elif key in ["PythonInterpreter", "Python3Interpreter"]: # This code is here to ensure backward compatibility. - if key == "PythonInterpreter": - newKey = "Python2VirtualEnv" - else: - newKey = "Python3VirtualEnv" + # Keep "PythonInterpreter" for backward compatibility. + newKey = "Python3VirtualEnv" venvName = prefClass.settings.value( "Debugger/" + newKey, prefClass.debuggerDefaults[newKey]) if venvName: @@ -1777,11 +1733,9 @@ else: interpreter = "" if not interpreter: - pyVersion = 2 if key == "PythonInterpreter" else 3 - if sys.version_info[0] == pyVersion: - return sys.executable + return sys.executable return interpreter - elif key in ["DebugClientType", "DebugClientType3"]: + elif key == "DebugClientType3": debugClientType = prefClass.settings.value( "Debugger/" + key, prefClass.debuggerDefaults[key]) # Correct obsolete entry "threaded" @@ -1789,6 +1743,12 @@ return "standard" else: return debugClientType + elif key == "PythonExtensions": + # we don't support Python2 anymore + return "" + elif key == "Python2VirtualEnv": + # we don't support Python2 anymore + return "" else: return prefClass.settings.value( "Debugger/" + key, prefClass.debuggerDefaults[key]) @@ -1813,7 +1773,11 @@ @param prefClass preferences class used as the storage area @return the requested debugger setting """ - if key in ["PythonExtensions", "Python3Extensions"]: + if key == "PythonExtensions": + # we don't support Python2 anymore + return [] + + if key == "Python3Extensions": exts = [] for ext in getDebugger(key, prefClass).split(): if ext.startswith("."): @@ -1833,7 +1797,7 @@ @param value the value to be set @param prefClass preferences class used as the storage area """ - if key in ["PythonExtensions", "Python3Extensions"]: + if key == "Python3Extensions": setDebugger(key, value, prefClass) @@ -2630,7 +2594,7 @@ else: return prefClass.settings.value( "MultiProject/" + key, prefClass.multiProjectDefaults[key]) - + def setMultiProject(key, value, prefClass=Prefs): """ @@ -2641,24 +2605,7 @@ @param prefClass preferences class used as the storage area """ prefClass.settings.setValue("MultiProject/" + key, value) - -def getQt4DocDir(prefClass=Prefs): - """ - Module function to retrieve the Qt4DocDir setting. - - @param prefClass preferences class used as the storage area - @return the requested Qt4DocDir setting (string) - """ - s = prefClass.settings.value( - "Help/Qt4DocDir", prefClass.helpDefaults["Qt4DocDir"]) - if s == "": - s = os.getenv("QT4DOCDIR", "") - if s == "": - s = os.path.join( - QLibraryInfo.location(QLibraryInfo.DocumentationPath), "html") - return s - def getQt5DocDir(prefClass=Prefs): """