Module: kamailio Branch: master Commit: 8bb866895c9260fa91143e892a2a77bb1d3fff4b URL: https://github.com/kamailio/kamailio/commit/8bb866895c9260fa91143e892a2a77bb...
Author: Anthony Messina amessina@messinet.com Committer: Anthony Messina amessina@messinet.com Date: 2018-12-14T16:32:04-06:00
app_python3: fix Python 3.7 deprecation warnings - check for PY_VERSION_HEX >= 0x03070000
---
Modified: src/modules/app_python3/app_python3_mod.c Modified: src/modules/app_python3/python_support.c Modified: src/modules/app_python3/python_support.h
---
Diff: https://github.com/kamailio/kamailio/commit/8bb866895c9260fa91143e892a2a77bb... Patch: https://github.com/kamailio/kamailio/commit/8bb866895c9260fa91143e892a2a77bb...
---
diff --git a/src/modules/app_python3/app_python3_mod.c b/src/modules/app_python3/app_python3_mod.c index fcc42fa899..464caadb35 100644 --- a/src/modules/app_python3/app_python3_mod.c +++ b/src/modules/app_python3/app_python3_mod.c @@ -177,7 +177,11 @@ static int child_init(int rank) return 0; } _apy_process_rank = rank; +#if PY_VERSION_HEX >= 0x03070000 + PyOS_AfterFork_Child(); +#else PyOS_AfterFork(); +#endif if (cfg_child_init()) { return -1; } @@ -431,7 +435,11 @@ int apy_init_script(int rank) { PyObject *pFunc, *pArgs, *pValue, *pResult; int rval = -1; +#if PY_VERSION_HEX >= 0x03070000 + const char *classname; +#else char *classname; +#endif PyGILState_STATE gstate;
diff --git a/src/modules/app_python3/python_support.c b/src/modules/app_python3/python_support.c index e7dc47d526..0a8216f133 100644 --- a/src/modules/app_python3/python_support.c +++ b/src/modules/app_python3/python_support.c @@ -234,10 +234,18 @@ static char *make_message(const char *fmt, va_list ap) return NULL; // shall not happened, but who knows ;) }
+#if PY_VERSION_HEX >= 0x03070000 +const char *get_class_name(PyObject *y) +#else char *get_class_name(PyObject *y) +#endif { PyObject *p; +#if PY_VERSION_HEX >= 0x03070000 + const char *name; +#else char *name; +#endif
p = PyObject_GetAttrString(y, "__name__"); if (p == NULL || p == Py_None) @@ -253,10 +261,18 @@ char *get_class_name(PyObject *y) }
+#if PY_VERSION_HEX >= 0x03070000 +const char *get_instance_class_name(PyObject *y) +#else char *get_instance_class_name(PyObject *y) +#endif { PyObject *p, *n; +#if PY_VERSION_HEX >= 0x03070000 + const char *name; +#else char *name; +#endif
n = PyObject_GetAttrString(y, "__class__"); if (n == NULL || n == Py_None) diff --git a/src/modules/app_python3/python_support.h b/src/modules/app_python3/python_support.h index 4d25564119..97c4e72e3e 100644 --- a/src/modules/app_python3/python_support.h +++ b/src/modules/app_python3/python_support.h @@ -30,7 +30,12 @@ PyObject *format_exc_obj; void python_handle_exception(const char *, ...);
PyObject *InitTracebackModule(void); +#if PY_VERSION_HEX >= 0x03070000 +const char *get_class_name(PyObject *); +const char *get_instance_class_name(PyObject *); +#else char *get_class_name(PyObject *); char *get_instance_class_name(PyObject *); +#endif
#endif