diff --git a/ChangeLog b/ChangeLog index 94ddf6b1f..76e6342a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] * core: display a warning in case of inconsistency between the options weechat.look.save_{config|layout}_on_exit * api: add integer return code for functions hook_{signal|hsignal}_send +* python: fix interpreter used after unload of a script == Version 0.4.3 (2014-02-09) diff --git a/src/plugins/python/weechat-python.c b/src/plugins/python/weechat-python.c index e0b556cad..e4936f3b7 100644 --- a/src/plugins/python/weechat-python.c +++ b/src/plugins/python/weechat-python.c @@ -795,7 +795,6 @@ weechat_python_unload (struct t_plugin_script *script) { int *rc; void *interpreter; - PyThreadState *old_interpreter; char *filename; if ((weechat_python_plugin->debug >= 2) || !python_quiet) @@ -814,12 +813,13 @@ weechat_python_unload (struct t_plugin_script *script) } filename = strdup (script->filename); - old_interpreter = PyThreadState_Swap (NULL); interpreter = script->interpreter; if (python_current_script == script) + { python_current_script = (python_current_script->prev_script) ? python_current_script->prev_script : python_current_script->next_script; + } plugin_script_remove (weechat_python_plugin, &python_scripts, &last_python_script, script); @@ -830,8 +830,8 @@ weechat_python_unload (struct t_plugin_script *script) Py_EndInterpreter (interpreter); } - if (old_interpreter) - PyThreadState_Swap (old_interpreter); + if (python_current_script) + PyThreadState_Swap (python_current_script->interpreter); (void) weechat_hook_signal_send ("python_script_unloaded", WEECHAT_HOOK_SIGNAL_STRING, filename);