127 lines
5.1 KiB
Diff
127 lines
5.1 KiB
Diff
--- domoticz-2021.1/hardware/plugins/DelayedLink.h.orig 2021-04-17 10:50:55.000000000 -0500
|
|
+++ domoticz-2021.1/hardware/plugins/DelayedLink.h 2021-12-16 22:47:43.549253877 -0600
|
|
@@ -9,6 +9,7 @@
|
|
#ifdef WITH_THREAD
|
|
# undefine WITH_THREAD
|
|
#endif
|
|
+#define PY_SSIZE_T_CLEAN
|
|
#include <Python.h>
|
|
#include <structmember.h>
|
|
#include <frameobject.h>
|
|
@@ -109,10 +110,10 @@
|
|
DECLARE_PYTHON_SYMBOL(PyObject*, PyModule_Create2, struct PyModuleDef* COMMA int);
|
|
#endif
|
|
DECLARE_PYTHON_SYMBOL(int, PyModule_AddObject, PyObject* COMMA const char* COMMA PyObject*);
|
|
- DECLARE_PYTHON_SYMBOL(int, PyArg_ParseTuple, PyObject* COMMA const char* COMMA ...);
|
|
- DECLARE_PYTHON_SYMBOL(int, PyArg_ParseTupleAndKeywords, PyObject* COMMA PyObject* COMMA const char* COMMA char*[] COMMA ...);
|
|
+ DECLARE_PYTHON_SYMBOL(int, _PyArg_ParseTuple_SizeT, PyObject* COMMA const char* COMMA ...);
|
|
+ DECLARE_PYTHON_SYMBOL(int, _PyArg_ParseTupleAndKeywords_SizeT, PyObject* COMMA PyObject* COMMA const char* COMMA char*[] COMMA ...);
|
|
DECLARE_PYTHON_SYMBOL(PyObject*, PyUnicode_FromFormat, const char* COMMA ...);
|
|
- DECLARE_PYTHON_SYMBOL(PyObject*, Py_BuildValue, const char* COMMA ...);
|
|
+ DECLARE_PYTHON_SYMBOL(PyObject*, _Py_BuildValue_SizeT, const char* COMMA ...);
|
|
DECLARE_PYTHON_SYMBOL(void, PyMem_Free, void*);
|
|
DECLARE_PYTHON_SYMBOL(PyObject*, PyBool_FromLong, long);
|
|
DECLARE_PYTHON_SYMBOL(int, PyRun_SimpleStringFlags, const char* COMMA PyCompilerFlags*);
|
|
@@ -249,10 +250,10 @@
|
|
RESOLVE_PYTHON_SYMBOL(PyModule_Create2);
|
|
#endif
|
|
RESOLVE_PYTHON_SYMBOL(PyModule_AddObject);
|
|
- RESOLVE_PYTHON_SYMBOL(PyArg_ParseTuple);
|
|
- RESOLVE_PYTHON_SYMBOL(PyArg_ParseTupleAndKeywords);
|
|
+ RESOLVE_PYTHON_SYMBOL(_PyArg_ParseTuple_SizeT);
|
|
+ RESOLVE_PYTHON_SYMBOL(_PyArg_ParseTupleAndKeywords_SizeT);
|
|
RESOLVE_PYTHON_SYMBOL(PyUnicode_FromFormat);
|
|
- RESOLVE_PYTHON_SYMBOL(Py_BuildValue);
|
|
+ RESOLVE_PYTHON_SYMBOL(_Py_BuildValue_SizeT);
|
|
RESOLVE_PYTHON_SYMBOL(PyMem_Free);
|
|
#ifdef _DEBUG
|
|
RESOLVE_PYTHON_SYMBOL(_Py_Dealloc);
|
|
@@ -460,8 +461,8 @@
|
|
#define PyObject_IsInstance pythonLib->PyObject_IsInstance
|
|
#define PyObject_IsSubclass pythonLib->PyObject_IsSubclass
|
|
#define PyObject_Dir pythonLib->PyObject_Dir
|
|
-#define PyArg_ParseTuple pythonLib->PyArg_ParseTuple
|
|
-#define Py_BuildValue pythonLib->Py_BuildValue
|
|
+#define PyArg_ParseTuple pythonLib->_PyArg_ParseTuple_SizeT
|
|
+#define Py_BuildValue pythonLib->_Py_BuildValue_SizeT
|
|
#define PyMem_Free pythonLib->PyMem_Free
|
|
#ifdef _DEBUG
|
|
# define PyModule_Create2TraceRefs pythonLib->PyModule_Create2TraceRefs
|
|
@@ -469,7 +470,7 @@
|
|
# define PyModule_Create2 pythonLib->PyModule_Create2
|
|
#endif
|
|
#define PyModule_AddObject pythonLib->PyModule_AddObject
|
|
-#define PyArg_ParseTupleAndKeywords pythonLib->PyArg_ParseTupleAndKeywords
|
|
+#define PyArg_ParseTupleAndKeywords pythonLib->_PyArg_ParseTupleAndKeywords_SizeT
|
|
|
|
#ifdef _DEBUG
|
|
# define _Py_Dealloc pythonLib->_Py_Dealloc
|
|
--- domoticz-2021.1/hardware/plugins/PluginManager.cpp.orig 2021-04-17 10:50:55.000000000 -0500
|
|
+++ domoticz-2021.1/hardware/plugins/PluginManager.cpp 2021-12-16 10:37:07.768344269 -0600
|
|
@@ -31,7 +31,7 @@
|
|
#include "DelayedLink.h"
|
|
#include "../../main/EventsPythonModule.h"
|
|
|
|
-#define MINIMUM_PYTHON_VERSION "3.4.0"
|
|
+#define MINIMUM_PYTHON_VERSION "3.10.0"
|
|
|
|
#define ATTRIBUTE_VALUE(pElement, Name, Value) \
|
|
{ \
|
|
@@ -111,6 +111,16 @@
|
|
return false;
|
|
}
|
|
|
|
+ Py_Initialize();
|
|
+
|
|
+ // Initialise threads. Python 3.7+ does this inside Py_Initialize so done here for compatibility
|
|
+ if (!PyEval_ThreadsInitialized())
|
|
+ {
|
|
+ PyEval_InitThreads();
|
|
+ }
|
|
+
|
|
+ m_InitialPythonThread = PyEval_SaveThread();
|
|
+
|
|
// Set program name, this prevents it being set to 'python'
|
|
Py_SetProgramName(Py_GetProgramFullPath());
|
|
|
|
@@ -132,16 +142,6 @@
|
|
return false;
|
|
}
|
|
|
|
- Py_Initialize();
|
|
-
|
|
- // Initialise threads. Python 3.7+ does this inside Py_Initialize so done here for compatibility
|
|
- if (!PyEval_ThreadsInitialized())
|
|
- {
|
|
- PyEval_InitThreads();
|
|
- }
|
|
-
|
|
- m_InitialPythonThread = PyEval_SaveThread();
|
|
-
|
|
m_bEnabled = true;
|
|
_log.Log(LOG_STATUS, "PluginSystem: Started, Python version '%s', %d plugin definitions loaded.", sVersion.c_str(), (int)m_PluginXml.size());
|
|
}
|
|
--- domoticz-2021.1/hardware/plugins/Plugins.cpp.orig 2021-12-16 10:37:07.768344269 -0600
|
|
+++ domoticz-2021.1/hardware/plugins/Plugins.cpp 2021-12-16 10:37:07.768344269 -0600
|
|
@@ -2268,6 +2269,7 @@
|
|
{
|
|
if (PyErr_Occurred())
|
|
{
|
|
+ LogPythonException(sHandler);
|
|
PyErr_Clear();
|
|
Log(LOG_NORM, "Python exception set prior to callback '%s'", sHandler.c_str());
|
|
}
|
|
@@ -2294,7 +2296,11 @@
|
|
}
|
|
|
|
if (m_bDebug & PDM_QUEUE)
|
|
- Log(LOG_NORM, "Calling message handler '%s' on '%s' type object.", sHandler.c_str(), pTarget->ob_type->tp_name);
|
|
+ {
|
|
+ PyObject *reprParams = PyObject_Repr(pParams);
|
|
+ const char *sParams = PyUnicode_AsUTF8(reprParams);
|
|
+ Log(LOG_NORM, "(%s) Calling message handler '%s' with parameters '%s'.", m_Name.c_str(), sHandler.c_str(), sParams);
|
|
+ }
|
|
|
|
PyErr_Clear();
|
|
|