Fixed python_plugin_interface.cpp -> logErrorMessage() to correctly display exception messages
@@ -611,15 +611,15 @@ static void logErrorMessage()
//Get error message
PyObject *pType, *pValue, *pTraceback;
PyErr_Fetch(&pType, &pValue, &pTraceback);
+ PyErr_NormalizeException(&pType, &pValue, &pTraceback);
- // NOTE from :
- // https://docs.python.org/2/c-api/exceptions.html
- //
- // The value and traceback object may be NULL
- // even when the type object is not.
- const char* pErrorMessage = pValue ?
- PyBytes_AsString(pValue) :
- "no error description.";
+ PyObject* str_exc_type = PyObject_Repr(pType);
+ PyObject* pyStr = PyUnicode_AsEncodedString(str_exc_type, "utf-8", "Error ~");
+ const char *strExcType = PyBytes_AS_STRING(pyStr);
+
+ PyObject* str_exc_value = PyObject_Repr(pValue);
+ PyObject* pyExcValueStr = PyUnicode_AsEncodedString(str_exc_value, "utf-8", "Error ~");
+ const char *pErrorMessage = PyBytes_AS_STRING(pyExcValueStr);
Logger::getLogger()->fatal("logErrorMessage: Error '%s' ",
pErrorMessage ?
