Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address code review
  • Loading branch information
corona10 committed Nov 14, 2022
commit 4ad2b8f173259a73ae42e1e321d9e2e49118a3ed
9 changes: 5 additions & 4 deletions Modules/syslogmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static PyObject *S_ident_o = NULL; // identifier, held by openlog()
static char S_log_open = 0;

static inline int
is_main_interpreter()
is_main_interpreter(void)
{
Comment thread
corona10 marked this conversation as resolved.
PyInterpreterState *main_interp = PyInterpreterState_Main();
PyThreadState *tstate = PyThreadState_GET();
Expand Down Expand Up @@ -150,7 +150,7 @@ syslog_openlog_impl(PyObject *module, PyObject *ident, long logopt,
// Since the sys.openlog changes the process level state of syslog library,
// this operation is only allowed for the main interpreter.
if (!is_main_interpreter()) {
PyErr_SetString(PyExc_RuntimeError, "unable to use syslog.openlog at non-main interpreter.");
PyErr_SetString(PyExc_RuntimeError, "subinterpreter can not use syslog.openlog");
Comment thread
corona10 marked this conversation as resolved.
Outdated
return NULL;
}

Expand Down Expand Up @@ -215,7 +215,8 @@ syslog_syslog_impl(PyObject *module, int group_left_1, int priority,
/* if log is not opened, open it now */
if (!S_log_open) {
if (!is_main_interpreter()) {
PyErr_SetString(PyExc_RuntimeError, "unable to use syslog.syslog at non-main interpreter for the first time.");
PyErr_SetString(PyExc_RuntimeError, "subinterpreter can't use syslog.syslog "
Comment thread
corona10 marked this conversation as resolved.
Outdated
"until the syslog is opened by the main interpreter");
return NULL;
}
PyObject *openlog_ret = syslog_openlog_impl(module, NULL, 0, LOG_USER);
Expand Down Expand Up @@ -256,7 +257,7 @@ syslog_closelog_impl(PyObject *module)
// Since the sys.closelog changes the process level state of syslog library,
// this operation is only allowed for the main interpreter.
if (!is_main_interpreter()) {
PyErr_SetString(PyExc_RuntimeError, "unable to use syslog.closelog at non-main interpreter.");
PyErr_SetString(PyExc_RuntimeError, "sunbinterpreter can not use syslog.closelog");
Comment thread
corona10 marked this conversation as resolved.
Outdated
return NULL;
}

Expand Down