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

Cherry-pick upstream fixes to support building against python3 libraries #201

Merged
merged 2 commits into from
Jun 22, 2022
Merged
Changes from all commits
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
16 changes: 16 additions & 0 deletions src/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,8 +1136,18 @@ static void *cpy_interactive(void *pipefd) {
cpy_log_exception("interactive session init");
}
cur_sig = PyOS_setsig(SIGINT, python_sigint_handler);
#if PY_VERSION_HEX < 0x03070000
PyOS_AfterFork();
#else
PyOS_AfterFork_Child();
#endif
#if PY_VERSION_HEX < 0x03090000
// deprecated. Called by Py_Initialize(). Removed in Py3.11
// https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads
PyEval_InitThreads();
#else
Py_Initialize();
#endif
close(*(int *)pipefd);
PyRun_InteractiveLoop(stdin, "<stdin>");
PyOS_setsig(SIGINT, cur_sig);
Expand Down Expand Up @@ -1174,7 +1184,13 @@ static int cpy_init(void) {
;
(void)close(pipefd[0]);
} else {
#if PY_VERSION_HEX < 0x03090000
// deprecated. Called by Py_Initialize(). Removed in Py3.11
// https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads
PyEval_InitThreads();
#else
Py_Initialize();
#endif
state = PyEval_SaveThread();
}
CPY_LOCK_THREADS
Expand Down