Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app_python3: fix Python 3.7 deprecation warnings #1767

Merged
merged 1 commit into from
Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/modules/app_python3/app_python3_mod.c
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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