### app_python (Python2) ``` make[2]: Entering directory '/builddir/build/BUILD/kamailio-5.2.0/src/modules/app_python' gcc -fPIC -DPIC -g -funroll-loops -Wcast-align -m64 -minline-all-stringops -falign-loops -ftree-vectorize -fno-strict-overflow -mtune=generic -Wall -DNAME='"kamailio"' -DVERSION='"5.2.0"' -DARCH='"x86_64"' -DOS='linux_' -DOS_QUOTED='"linux"' -DCOMPILER='"gcc 8.2.1"' -D__CPU_x86_64 -D__OS_linux -DVERSIONVAL=5002000 -DCFG_DIR='"/etc/kamailio/"' -DSHARE_DIR='"/usr/share/kamailio/"' -DRUN_DIR='"/var/run/kamailio/"' -DPKG_MALLOC -DSHM_MEM -DSHM_MMAP -DDNS_IP_HACK -DUSE_MCAST -DUSE_TCP -DDISABLE_NAGLE -DHAVE_RESOLV_RES -DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLACKLIST -DUSE_NAPTR -DWITH_XAVP -DMEM_JOIN_FREE -DF_MALLOC -DQ_MALLOC -DTLSF_MALLOC -DDBG_SR_MEMORY -DUSE_TLS -DTLS_HOOKS -DUSE_CORE_STATS -DSTATISTICS -DMALLOC_STATS -DWITH_AS_SUPPORT -DUSE_SCTP -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DCC_GCC_LIKE_ASM -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER -DHAVE_IP_MREQN -DUSE_RAW_SOCKS -DHAVE_EPOLL -DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND -DUSE_FUTEX -DHAVE_SELECT -I/usr/include/python2.7 -DMOD_NAME='"app_python"' -c apy_kemi_export.c -o apy_kemi_export.o -MMD -MP make[2]: Leaving directory '/builddir/build/BUILD/kamailio-5.2.0/src/modules/app_python' BUILDSTDERR: In file included from /usr/include/python2.7/pyconfig.h:6, BUILDSTDERR: from /usr/include/python2.7/Python.h:8, BUILDSTDERR: from apy_kemi_export.c:30: BUILDSTDERR: /usr/include/python2.7/pyconfig-64.h:1232: warning: "_POSIX_C_SOURCE" redefined BUILDSTDERR: #define _POSIX_C_SOURCE 200112L BUILDSTDERR: BUILDSTDERR: In file included from /usr/include/bits/libc-header-start.h:33, BUILDSTDERR: from /usr/include/stdio.h:27, BUILDSTDERR: from apy_kemi_export.c:26: BUILDSTDERR: /usr/include/features.h:265: note: this is the location of the previous definition BUILDSTDERR: # define _POSIX_C_SOURCE 200809L ``` ``` make[2]: Entering directory '/builddir/build/BUILD/kamailio-5.2.0/src/modules/app_python' gcc -fPIC -DPIC -g -funroll-loops -Wcast-align -m64 -minline-all-stringops -falign-loops -ftree-vectorize -fno-strict-overflow -mtune=generic -Wall -DNAME='"kamailio"' -DVERSION='"5.2.0"' -DARCH='"x86_64"' -DOS='linux_' -DOS_QUOTED='"linux"' -DCOMPILER='"gcc 8.2.1"' -D__CPU_x86_64 -D__OS_linux -DVERSIONVAL=5002000 -DCFG_DIR='"/etc/kamailio/"' -DSHARE_DIR='"/usr/share/kamailio/"' -DRUN_DIR='"/var/run/kamailio/"' -DPKG_MALLOC -DSHM_MEM -DSHM_MMAP -DDNS_IP_HACK -DUSE_MCAST -DUSE_TCP -DDISABLE_NAGLE -DHAVE_RESOLV_RES -DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLACKLIST -DUSE_NAPTR -DWITH_XAVP -DMEM_JOIN_FREE -DF_MALLOC -DQ_MALLOC -DTLSF_MALLOC -DDBG_SR_MEMORY -DUSE_TLS -DTLS_HOOKS -DUSE_CORE_STATS -DSTATISTICS -DMALLOC_STATS -DWITH_AS_SUPPORT -DUSE_SCTP -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DCC_GCC_LIKE_ASM -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER -DHAVE_IP_MREQN -DUSE_RAW_SOCKS -DHAVE_EPOLL -DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND -DUSE_FUTEX -DHAVE_SELECT -I/usr/include/python2.7 -DMOD_NAME='"app_python"' -c apy_kemi.c -o apy_kemi.o -MMD -MP make[2]: Leaving directory '/builddir/build/BUILD/kamailio-5.2.0/src/modules/app_python' BUILDSTDERR: In file included from /usr/include/python2.7/pyconfig.h:6, BUILDSTDERR: from /usr/include/python2.7/Python.h:8, BUILDSTDERR: from apy_kemi.c:25: BUILDSTDERR: /usr/include/python2.7/pyconfig-64.h:1232: warning: "_POSIX_C_SOURCE" redefined BUILDSTDERR: #define _POSIX_C_SOURCE 200112L BUILDSTDERR: BUILDSTDERR: In file included from /usr/include/bits/libc-header-start.h:33, BUILDSTDERR: from /usr/include/stdio.h:27, BUILDSTDERR: from apy_kemi.c:21: BUILDSTDERR: /usr/include/features.h:265: note: this is the location of the previous definition BUILDSTDERR: # define _POSIX_C_SOURCE 200809L ``` ### app_python3 (Python3) ``` make[2]: Entering directory '/builddir/build/BUILD/kamailio-5.2.0/src/modules/app_python3' gcc -fPIC -DPIC -g -funroll-loops -Wcast-align -m64 -minline-all-stringops -falign-loops -ftree-vectorize -fno-strict-overflow -mtune=generic -Wall -DNAME='"kamailio"' -DVERSION='"5.2.0"' -DARCH='"x86_64"' -DOS='linux_' -DOS_QUOTED='"linux"' -DCOMPILER='"gcc 8.2.1"' -D__CPU_x86_64 -D__OS_linux -DVERSIONVAL=5002000 -DCFG_DIR='"/etc/kamailio/"' -DSHARE_DIR='"/usr/share/kamailio/"' -DRUN_DIR='"/var/run/kamailio/"' -DPKG_MALLOC -DSHM_MEM -DSHM_MMAP -DDNS_IP_HACK -DUSE_MCAST -DUSE_TCP -DDISABLE_NAGLE -DHAVE_RESOLV_RES -DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLACKLIST -DUSE_NAPTR -DWITH_XAVP -DMEM_JOIN_FREE -DF_MALLOC -DQ_MALLOC -DTLSF_MALLOC -DDBG_SR_MEMORY -DUSE_TLS -DTLS_HOOKS -DUSE_CORE_STATS -DSTATISTICS -DMALLOC_STATS -DWITH_AS_SUPPORT -DUSE_SCTP -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DCC_GCC_LIKE_ASM -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER -DHAVE_IP_MREQN -DUSE_RAW_SOCKS -DHAVE_EPOLL -DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND -DUSE_FUTEX -DHAVE_SELECT -I/usr/include/python3.7m -DMOD_NAME='"app_python3"' -c python_support.c -o python_support.o -MMD -MP BUILDSTDERR: python_support.c: In function 'get_class_name': BUILDSTDERR: python_support.c:249:7: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] BUILDSTDERR: name = PyUnicode_AsUTF8(p); BUILDSTDERR: ^ BUILDSTDERR: python_support.c: In function 'get_instance_class_name': BUILDSTDERR: python_support.c:275:7: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] BUILDSTDERR: name = PyUnicode_AsUTF8(p); BUILDSTDERR: ^ ``` ``` gcc -fPIC -DPIC -g -funroll-loops -Wcast-align -m64 -minline-all-stringops -falign-loops -ftree-vectorize -fno-strict-overflow -mtune=generic -Wall -DNAME='"kamailio"' -DVERSION='"5.2.0"' -DARCH='"x86_64"' -DOS='linux_' -DOS_QUOTED='"linux"' -DCOMPILER='"gcc 8.2.1"' -D__CPU_x86_64 -D__OS_linux -DVERSIONVAL=5002000 -DCFG_DIR='"/etc/kamailio/"' -DSHARE_DIR='"/usr/share/kamailio/"' -DRUN_DIR='"/var/run/kamailio/"' -DPKG_MALLOC -DSHM_MEM -DSHM_MMAP -DDNS_IP_HACK -DUSE_MCAST -DUSE_TCP -DDISABLE_NAGLE -DHAVE_RESOLV_RES -DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLACKLIST -DUSE_NAPTR -DWITH_XAVP -DMEM_JOIN_FREE -DF_MALLOC -DQ_MALLOC -DTLSF_MALLOC -DDBG_SR_MEMORY -DUSE_TLS -DTLS_HOOKS -DUSE_CORE_STATS -DSTATISTICS -DMALLOC_STATS -DWITH_AS_SUPPORT -DUSE_SCTP -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DCC_GCC_LIKE_ASM -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER -DHAVE_IP_MREQN -DUSE_RAW_SOCKS -DHAVE_EPOLL -DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND -DUSE_FUTEX -DHAVE_SELECT -I/usr/include/python3.7m -DMOD_NAME='"app_python3"' -c python_exec.c -o python_exec.o -MMD -MP make[2]: Leaving directory '/builddir/build/BUILD/kamailio-5.2.0/src/modules/app_python3' BUILDSTDERR: app_python3_mod.c: In function 'child_init': BUILDSTDERR: app_python3_mod.c:180:2: warning: 'PyOS_AfterFork' is deprecated [-Wdeprecated-declarations] BUILDSTDERR: PyOS_AfterFork(); BUILDSTDERR: ^~~~~~~~~~~~~~ BUILDSTDERR: In file included from /usr/include/python3.7m/Python.h:125, BUILDSTDERR: from app_python3_mod.c:22: BUILDSTDERR: /usr/include/python3.7m/intrcheck.h:18:18: note: declared here BUILDSTDERR: PyAPI_FUNC(void) PyOS_AfterFork(void) Py_DEPRECATED(3.7); BUILDSTDERR: ^~~~~~~~~~~~~~ ```
The following patch resolves the app_python3 build errors (Which are changes with Python 3.7). Fedora 29 includes Python 3.7 released on 06/27/2018. ``` diff --git a/src/modules/app_python3/app_python3_mod.c b/src/modules/app_python3/app_python3_mod.c index fcc42fa89..00f7e2ced 100644 --- a/src/modules/app_python3/app_python3_mod.c +++ b/src/modules/app_python3/app_python3_mod.c @@ -177,7 +177,7 @@ static int child_init(int rank) return 0; } _apy_process_rank = rank; - PyOS_AfterFork(); + PyOS_AfterFork_Child(); if (cfg_child_init()) { return -1; } @@ -431,7 +431,7 @@ int apy_init_script(int rank) { PyObject *pFunc, *pArgs, *pValue, *pResult; int rval = -1; - char *classname; + const char *classname; PyGILState_STATE gstate;
diff --git a/src/modules/app_python3/python_support.c b/src/modules/app_python3/python_support.c index e7dc47d52..14ba3283f 100644 --- a/src/modules/app_python3/python_support.c +++ b/src/modules/app_python3/python_support.c @@ -234,10 +234,10 @@ static char *make_message(const char *fmt, va_list ap) return NULL; // shall not happened, but who knows ;) }
-char *get_class_name(PyObject *y) +const char *get_class_name(PyObject *y) { PyObject *p; - char *name; + const char *name;
p = PyObject_GetAttrString(y, "__name__"); if (p == NULL || p == Py_None) @@ -253,10 +253,10 @@ char *get_class_name(PyObject *y) }
-char *get_instance_class_name(PyObject *y) +const char *get_instance_class_name(PyObject *y) { PyObject *p, *n; - char *name; + const char *name;
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 4d2556411..b3823da76 100644 --- a/src/modules/app_python3/python_support.h +++ b/src/modules/app_python3/python_support.h @@ -30,7 +30,7 @@ PyObject *format_exc_obj; void python_handle_exception(const char *, ...);
PyObject *InitTracebackModule(void); -char *get_class_name(PyObject *); -char *get_instance_class_name(PyObject *); +const char *get_class_name(PyObject *); +const char *get_instance_class_name(PyObject *);
#endif ```
@amessina - just make a pull request for the patch, it is easier to merge, thanks!
@miconda ok, I'll need to figure out how to do that ;)
I also need to figure out how to do `if Python >=3.7` since these warnings come from changes with the Python 3.7 release. I'm sure some stable enterprise-type distros might not yet be using 3.7.
@amessina - I see that you can get the version numbers via defines, for example header files for python 3.5.3 has the following defines:
``` #define PY_MAJOR_VERSION 3 #define PY_MINOR_VERSION 5 #define PY_MICRO_VERSION 3 ``` So you can have:
``` #if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 7 ... #endif ```
Ok @miconda, I think I learned how to do all the Github related stuff and went with the `#if PY_VERSION_HEX >= 0x03070000` style of version checking based on https://docs.python.org/3/c-api/apiabiversion.html
While this patch "fixes" the Python3.7 deprecation warnings, I don't know how the project overall likes to handle things like this. I'm guessing that true devs would prefer to NOT litter code with `#if #endif` statements, but that's for you guys to decide.
Thank you for letting me try to contribute.
I don't know how the project overall likes to handle things like this. I'm guessing that true devs would prefer to NOT litter code with #if #endif statements, but that's for you guys to decide.
There is no general policy against #if pre-processor statements in the code. Sure, we try to avoid them if possible. But in this particular case where its necessary to ensure compatibility with different libraries, it is of course fine. This is used also in other modules.
Lets wait a bit if Daniel has some comments on the referenced pull request. Otherwise I can also merge it, for me it looks fine.
The referenced patch was merged a while ago, so I guess this one can be closed, if still something to do, reopen or create a new one.
Closed #1748.