Skip to content

Commit

Permalink
Merge pull request #1646 from michaelortmann/python.reload
Browse files Browse the repository at this point in the history
Crashfix: Forbid unloading of python mod
  • Loading branch information
skralg authored Jul 12, 2024
2 parents 606dc7b + 120ca58 commit d2f93d5
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/mod/python.mod/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ static char *init_python() {
return NULL;
}

static void kill_python() {
if (Py_FinalizeEx() < 0) {
exit(120);
}
return;
}

static void python_report(int idx, int details)
{
if (details)
Expand All @@ -119,13 +112,13 @@ static void python_report(int idx, int details)

static char *python_close()
{
del_hook(HOOK_PRE_SELECT, (Function)python_gil_unlock);
del_hook(HOOK_POST_SELECT, (Function)python_gil_lock);
kill_python();
rem_builtins(H_dcc, mydcc);
rem_tcl_commands(my_tcl_cmds);
module_undepend(MODULE_NAME);
return NULL;
/* Forbid unloading, because:
* - Reloading (Reexecuting PyDateTime_IMPORT) would crash
* - Py_FinalizeEx() does not clean up everything
* - Complexity regarding running python threads
* see https://bugs.python.org/issue34309 for details
*/
return "The " MODULE_NAME " module is not allowed to be unloaded.";
}

static Function python_table[] = {
Expand Down

0 comments on commit d2f93d5

Please sign in to comment.