Init: [skip ci] do explicitly open Init[Gui].py files with utf-8 encoding

This commit is contained in:
wmayer
2020-11-24 14:15:26 +01:00
parent 8d73c8f07f
commit 27ee19c1f7
2 changed files with 5 additions and 2 deletions

View File

@@ -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')

View File

@@ -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')