diff --git a/src/App/FreeCADInit.py b/src/App/FreeCADInit.py index 2de08ad6f..e539e6252 100644 --- a/src/App/FreeCADInit.py +++ b/src/App/FreeCADInit.py @@ -36,7 +36,7 @@ import FreeCAD def InitApplications(): try: - import sys,os + import sys,os,traceback,cStringIO except ImportError: FreeCAD.PrintError("\n\nSeems the python standard libs are not installed, bailing out!\n\n") raise @@ -96,7 +96,12 @@ def InitApplications(): exec open(InstallFile).read() except Exception, inst: Log('Init: Initializing ' + Dir + '... failed\n') - Err('During initialization the error ' + str(inst) + ' occurred in ' + InstallFile + '\n') + Log('-'*100+'\n') + output=cStringIO.StringIO() + traceback.print_exc(file=output) + Log(output.getvalue()) + Log('-'*100+'\n') + Err('During initialization the error ' + str(inst).decode('ascii','replace') + ' occurred in ' + InstallFile + '\n') else: Log('Init: Initializing ' + Dir + '... done\n') else: diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index bd0b1d347..dd403e022 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -159,7 +159,10 @@ std::string InterpreterSingleton::runString(const char *sCmd) presult = PyRun_String(sCmd, Py_file_input, dict, dict); /* eval direct */ if (!presult) { - throw PyException(); + if (PyErr_ExceptionMatches(PyExc_SystemExit)) + throw SystemExitException(); + else + throw PyException(); } PyObject* repr = PyObject_Repr(presult); diff --git a/src/Gui/FreeCADGuiInit.py b/src/Gui/FreeCADGuiInit.py index e702ab326..69f87f018 100644 --- a/src/Gui/FreeCADGuiInit.py +++ b/src/Gui/FreeCADGuiInit.py @@ -98,7 +98,7 @@ class NoneWorkbench ( Workbench ): return "Gui::NoneWorkbench" def InitApplications(): - import sys,os + import sys,os,traceback,cStringIO # Searching modules dirs +++++++++++++++++++++++++++++++++++++++++++++++++++ # (additional module paths are already cached) ModDirs = FreeCAD.__path__ @@ -113,7 +113,12 @@ def InitApplications(): exec open(InstallFile).read() except Exception, inst: Log('Init: Initializing ' + Dir + '... failed\n') - Err('During initialization the error ' + str(inst) + ' occurred in ' + InstallFile + '\n') + Log('-'*100+'\n') + output=cStringIO.StringIO() + traceback.print_exc(file=output) + Log(output.getvalue()) + Log('-'*100+'\n') + Err('During initialization the error ' + str(inst).decode('ascii','replace') + ' occurred in ' + InstallFile + '\n') else: Log('Init: Initializing ' + Dir + '... done\n') else: