1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-20 01:54:46 +02:00

python: call empty eval workaround before auto-load of scripts (issue #2046, issue #2126)

This should definitely fix the crash with Python 3.12, even when scripts are
auto-loaded (the previous fix was working only when the scripts are loaded
manually).
This commit is contained in:
Sébastien Helleu
2024-06-26 18:44:35 +02:00
parent e5725a366d
commit 486ea8837a
10 changed files with 33 additions and 6 deletions
+18 -6
View File
@@ -1088,6 +1088,23 @@ weechat_python_eval (struct t_gui_buffer *buffer, int send_to_buffer_as_input,
return 1;
}
/*
* Function called before the auto-load of scripts.
*/
void
weechat_python_init_before_autoload ()
{
#if PY_VERSION_HEX >= 0x030C0000 && PY_VERSION_HEX < 0x030D0000
/*
* Workaround for crash when ending interpreters in Python 3.12:
* the first time we load a script, we eval an empty string.
* See https://github.com/weechat/weechat/issues/2046
*/
weechat_python_eval (NULL, 0, 0, "");
#endif
}
/*
* Callback for command "/python".
*/
@@ -1592,6 +1609,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
python_data.callback_signal_debug_dump = &weechat_python_signal_debug_dump_cb;
python_data.callback_signal_script_action = &weechat_python_signal_script_action_cb;
python_data.callback_load_file = &weechat_python_load_cb;
python_data.init_before_autoload = &weechat_python_init_before_autoload;
python_data.unload_all = &weechat_python_unload_all;
old_python_quiet = python_quiet;
@@ -1613,12 +1631,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
"",
&weechat_python_infolist_cb, NULL, NULL);
#if PY_VERSION_HEX >= 0x030C0000 && PY_VERSION_HEX < 0x030D0000
// Workaround for crash when ending interpreters in Python 3.12
// See https://github.com/weechat/weechat/issues/2046
weechat_python_eval (NULL, 0, 0, "");
#endif
/* init OK */
return WEECHAT_RC_OK;
}