Py2: do not open Init[Gui].py files with utf-8 encoding

This commit is contained in:
wmayer
2020-11-26 00:48:28 +01:00
parent 527cf37afd
commit a0de713ca2
2 changed files with 12 additions and 7 deletions

View File

@@ -172,9 +172,12 @@ def InitApplications():
if (os.path.exists(InstallFile)):
try:
# XXX: This looks scary securitywise...
with codecs.open(filename=InstallFile, encoding="utf-8") as f:
exec(f.read())
if sys.version_info.major < 3:
with open(InstallFile) as f:
exec(f.read())
else:
with open(file=InstallFile, encoding="utf-8") as f:
exec(f.read())
except Exception as inst:
Log('Init: Initializing ' + Dir + '... failed\n')
Log('-'*100+'\n')
@@ -630,7 +633,6 @@ 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,7 +108,6 @@ class NoneWorkbench ( Workbench ):
def InitApplications():
import sys,os,traceback
import codecs
try:
# Python3
import io as cStringIO
@@ -126,8 +125,12 @@ def InitApplications():
if (os.path.exists(InstallFile)):
try:
# XXX: This looks scary securitywise...
with codecs.open(filename=InstallFile, encoding="utf-8") as f:
exec(f.read())
if sys.version_info.major < 3:
with open(InstallFile) as f:
exec(f.read())
else:
with open(file=InstallFile, encoding="utf-8") as f:
exec(f.read())
except Exception as inst:
Log('Init: Initializing ' + Dir + '... failed\n')
Log('-'*100+'\n')