Skip to content

Commit

Permalink
app_python3: fix Python 3.7 deprecation warnings
Browse files Browse the repository at this point in the history
- check for PY_VERSION_HEX >= 0x03070000
  • Loading branch information
amessina committed Dec 14, 2018
1 parent bbabc77 commit 8bb8668
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/modules/app_python3/app_python3_mod.c
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;


Expand Down
16 changes: 16 additions & 0 deletions src/modules/app_python3/python_support.c
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/modules/app_python3/python_support.h
Expand Up @@ -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

0 comments on commit 8bb8668

Please sign in to comment.