mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Fix excepthook for Python.
This commit is contained in:
@@ -4,58 +4,70 @@
|
||||
<context>
|
||||
<name>ProxyPython</name>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="166"/>
|
||||
<location filename="proxypython.cpp" line="121"/>
|
||||
<source>Python Initialization failed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="122"/>
|
||||
<source>On a previous start the Python Plugin failed to initialize.
|
||||
Do you want to try initializing python again (at the risk of another crash)?
|
||||
Suggestion: Select "no", and click the warning sign for further help.Afterwards you have to re-enable the python plugin.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="169"/>
|
||||
<source>Python Proxy</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="176"/>
|
||||
<location filename="proxypython.cpp" line="179"/>
|
||||
<source>Proxy Plugin to allow plugins written in python to be loaded</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="248"/>
|
||||
<location filename="proxypython.cpp" line="251"/>
|
||||
<source>ModOrganizer path contains a semicolon</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="250"/>
|
||||
<location filename="proxypython.cpp" line="253"/>
|
||||
<source>Python DLL not found</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="252"/>
|
||||
<location filename="proxypython.cpp" line="255"/>
|
||||
<source>Invalid Python DLL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="254"/>
|
||||
<location filename="proxypython.cpp" line="257"/>
|
||||
<source>Initializing Python failed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="256"/>
|
||||
<location filename="proxypython.cpp" line="286"/>
|
||||
<location filename="proxypython.cpp" line="259"/>
|
||||
<location filename="proxypython.cpp" line="289"/>
|
||||
<source>invalid problem key %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="264"/>
|
||||
<location filename="proxypython.cpp" line="267"/>
|
||||
<source>The path to Mod Organizer (%1) contains a semicolon. <br>While this is legal on NTFS drives, many softwares do not handle it correctly.<br>Unfortunately MO depends on libraries that seem to fall into that group.<br>As a result the python plugin cannot be loaded, and the only solution we canoffer is to remove the semicolon or move MO to a path without a semicolon.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="275"/>
|
||||
<location filename="proxypython.cpp" line="278"/>
|
||||
<source>The Python plugin DLL was not found, maybe your antivirus deleted it. Re-installing MO2 might fix the problem.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="278"/>
|
||||
<location filename="proxypython.cpp" line="281"/>
|
||||
<source>The Python plugin DLL is invalid, maybe your antivirus is blocking it. Re-installing MO2 and adding exclusions for it to your AV might fix the problem.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="proxypython.cpp" line="283"/>
|
||||
<location filename="proxypython.cpp" line="286"/>
|
||||
<source>The initialization of the Python plugin DLL failed, unfortunately without any details.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
||||
#include <pybind11/eval.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
|
||||
#include "log.h"
|
||||
@@ -67,8 +68,18 @@ namespace mo2::python {
|
||||
sys.attr("stdout") = printWrapper();
|
||||
sys.attr("stderr") = errorWrapper();
|
||||
|
||||
// not sure if still needed for pybind11?
|
||||
sys.attr("excepthook") = sys.attr("__excepthook__");
|
||||
// this is required to handle exception in Python code OUTSIDE of pybind11 call,
|
||||
// typically on Qt classes with methods overridden on the Python side
|
||||
//
|
||||
// without this, the application will crash instead of properly handling the
|
||||
// exception as it would do with a py::error_already_set{}
|
||||
//
|
||||
// IMPORTANT: sys.attr("excepthook") = sys.attr("__excepthook__") DOES NOT WORK,
|
||||
// and I have no clue why since the attribute does not seem to get updated (at
|
||||
// least a print does not show it)
|
||||
//
|
||||
sys.attr("excepthook") =
|
||||
py::eval("lambda x, y, z: sys.__excepthook__(x, y, z)");
|
||||
}
|
||||
|
||||
// Small structure to hold the levels - There are copy paste from
|
||||
|
||||
Reference in New Issue
Block a user