1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

python: add workaround for crash on unload with Python 3.12

Python 3.12 has a bug where it crashes when you unload all the
interpreters unless you make sure to unload the first interpreter you
loaded last. For some reason, loading the eval interpreter before any
scripts also seems to prevent the issue, even if the eval interpreter is
unloaded before the other interpreters.

So this just evals an empty string at the end of initing the Python
plugin if the Python version is 3.12, to make sure the eval interpreter
is loaded first.

Fixes #2046
This commit is contained in:
Trygve Aaberge
2024-06-04 00:15:33 +02:00
committed by Sébastien Helleu
parent 1cec7e8126
commit 35df848e73
+6
View File
@@ -1606,6 +1606,12 @@ 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;
}