From 5558d84a646dd4e39b1b6d7d246804fa1253f789 Mon Sep 17 00:00:00 2001 From: looooo Date: Thu, 9 Mar 2017 12:18:04 +0100 Subject: [PATCH] py3: App: FreeCADInit.py --- src/App/FreeCADInit.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/App/FreeCADInit.py b/src/App/FreeCADInit.py index ea588585ea..41281f01d0 100644 --- a/src/App/FreeCADInit.py +++ b/src/App/FreeCADInit.py @@ -36,7 +36,7 @@ import FreeCAD def InitApplications(): try: - import sys,os,traceback,cStringIO + import sys,os,traceback,io except ImportError: FreeCAD.Console.PrintError("\n\nSeems the python standard libs are not installed, bailing out!\n\n") raise @@ -88,7 +88,7 @@ def InitApplications(): PathExtension = BinDir + os.pathsep # prepend all module paths to Python search path Log('Init: Searching for modules...\n') - FreeCAD.__path__ = ModDict.values() + FreeCAD.__path__ = list(ModDict.values()) for Dir in ModDict.values(): if ((Dir != '') & (Dir != 'CVS') & (Dir != '__init__.py')): sys.path.insert(0,Dir) @@ -96,16 +96,15 @@ def InitApplications(): InstallFile = os.path.join(Dir,"Init.py") if (os.path.exists(InstallFile)): try: - #execfile(InstallFile) - exec open(InstallFile).read() - except Exception, inst: + # XXX: This looks scary securitywise... + with open(InstallFile) as f: + exec(f.read()) + except Exception as inst: Log('Init: Initializing ' + Dir + '... failed\n') Log('-'*100+'\n') - output=cStringIO.StringIO() - traceback.print_exc(file=output) - Log(output.getvalue()) + Log(traceback.format_exc()) Log('-'*100+'\n') - Err('During initialization the error ' + str(inst).decode('ascii','replace') + ' occurred in ' + InstallFile + '\n') + Err('During initialization the error ' + str(inst) + ' occurred in ' + InstallFile + '\n') else: Log('Init: Initializing ' + Dir + '... done\n') else: