From: Mattia Rizzolo Date: Sat, 25 May 2019 11:37:50 +0200 Subject: Python plugin: Call EndInterpreter when deinit'ing the plugin Commonly-encountered bug when using Hexchat 2.14 on Python 3.7. The next upstream release will have a completely rewritten Python plugin that won't need this patch (check the upstream bug). Bug: https://github.com/hexchat/hexchat/issues/2237 Bug-Debian: https://bugs.debian.org/921208 Bug-Ubuntu: https://bugs.launchpad.net/bug/1830246 Bug-Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=1632039 Author: @ncoghlan, on the upstream bug Forwarded: not-needed Signed-off-by: Mattia Rizzolo --- plugins/python/python.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/python/python.c b/plugins/python/python.c index 4403474..475756b 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -2806,6 +2806,9 @@ hexchat_plugin_deinit(void) xchatout_buffer = NULL; if (interp_plugin) { + PyThreadState *tstate = ((PluginObject*)interp_plugin)->tstate; + PyThreadState_Swap(tstate); + Py_EndInterpreter(tstate); Py_DECREF(interp_plugin); interp_plugin = NULL; }