diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index a2e7f7567..5a900ee31 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -854,11 +854,16 @@ weechat_plugin_end (t_weechat_plugin *plugin) weechat_python_unload_all (plugin); /* free Python interpreter */ - /*Py_Finalize (); + if (python_mainThreadState != NULL) + { + PyThreadState_Swap (python_mainThreadState); + python_mainThreadState = NULL; + } + Py_Finalize (); if (Py_IsInitialized () != 0) python_plugin->printf_server (python_plugin, "Python error: unable to free interpreter"); python_plugin->printf_server (python_plugin, - "Python plugin ended");*/ + "Python plugin ended"); } diff --git a/weechat/src/plugins/scripts/python/weechat-python.c b/weechat/src/plugins/scripts/python/weechat-python.c index a2e7f7567..5a900ee31 100644 --- a/weechat/src/plugins/scripts/python/weechat-python.c +++ b/weechat/src/plugins/scripts/python/weechat-python.c @@ -854,11 +854,16 @@ weechat_plugin_end (t_weechat_plugin *plugin) weechat_python_unload_all (plugin); /* free Python interpreter */ - /*Py_Finalize (); + if (python_mainThreadState != NULL) + { + PyThreadState_Swap (python_mainThreadState); + python_mainThreadState = NULL; + } + Py_Finalize (); if (Py_IsInitialized () != 0) python_plugin->printf_server (python_plugin, "Python error: unable to free interpreter"); python_plugin->printf_server (python_plugin, - "Python plugin ended");*/ + "Python plugin ended"); }