From 27ee19c1f72eec805c9d6d427967afd4ee8694cb Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 24 Nov 2020 14:15:26 +0100 Subject: [PATCH] Init: [skip ci] do explicitly open Init[Gui].py files with utf-8 encoding --- src/App/FreeCADInit.py | 4 +++- src/Gui/FreeCADGuiInit.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/App/FreeCADInit.py b/src/App/FreeCADInit.py index fbc09cc0fb..2edaa47436 100644 --- a/src/App/FreeCADInit.py +++ b/src/App/FreeCADInit.py @@ -45,6 +45,7 @@ def removeFromPath(module_name): def setupSearchPaths(PathExtension): # DLL resolution in Python 3.8 on Windows has changed + import sys, os if sys.platform == 'win32' and hasattr(os, "add_dll_directory"): if "FREECAD_LIBPACK_BIN" in os.environ: os.add_dll_directory(os.environ["FREECAD_LIBPACK_BIN"]) @@ -172,7 +173,7 @@ def InitApplications(): try: # XXX: This looks scary securitywise... - with open(InstallFile) as f: + with codecs.open(filename=InstallFile, encoding="utf-8") as f: exec(f.read()) except Exception as inst: Log('Init: Initializing ' + Dir + '... failed\n') @@ -629,6 +630,7 @@ FreeCAD.Logger = FCADLogger # init every application by importing Init.py try: import traceback + import codecs InitApplications() except Exception as e: Err('Error in InitApplications ' + str(e) + '\n') diff --git a/src/Gui/FreeCADGuiInit.py b/src/Gui/FreeCADGuiInit.py index e7ebbacafc..5899ae0287 100644 --- a/src/Gui/FreeCADGuiInit.py +++ b/src/Gui/FreeCADGuiInit.py @@ -108,6 +108,7 @@ class NoneWorkbench ( Workbench ): def InitApplications(): import sys,os,traceback + import codecs try: # Python3 import io as cStringIO @@ -125,7 +126,7 @@ def InitApplications(): if (os.path.exists(InstallFile)): try: # XXX: This looks scary securitywise... - with open(InstallFile) as f: + with codecs.open(filename=InstallFile, encoding="utf-8") as f: exec(f.read()) except Exception as inst: Log('Init: Initializing ' + Dir + '... failed\n')