diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index ddc511b22..1159a7a8d 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -36,6 +36,8 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] * relay: fix up/down keys on relay buffer (closes #335) * relay: remove v4-mapped addresses in /help relay.network.allowed_ips (closes #325) +* python: fix restore of old interpreter when a function is not found in the + script * scripts: fix type of value returned by function hdata_time (from string to long integer) in perl/ruby/lua/tcl/guile plugins diff --git a/src/plugins/python/weechat-python.c b/src/plugins/python/weechat-python.c index 21fd90b7b..9f0b0019b 100644 --- a/src/plugins/python/weechat-python.c +++ b/src/plugins/python/weechat-python.c @@ -319,9 +319,12 @@ weechat_python_exec (struct t_plugin_script *script, void *argv2[16], *ret_value; int i, argc, *ret_int; + ret_value = NULL; + /* PyEval_AcquireLock (); */ old_python_current_script = python_current_script; + python_current_script = script; old_interpreter = NULL; if (script->interpreter) { @@ -339,13 +342,9 @@ weechat_python_exec (struct t_plugin_script *script, weechat_gettext ("%s%s: unable to run function \"%s\""), weechat_prefix ("error"), PYTHON_PLUGIN_NAME, function); /* PyEval_ReleaseThread (python_current_script->interpreter); */ - if (old_interpreter) - PyThreadState_Swap (old_interpreter); - return NULL; + goto end; } - python_current_script = script; - if (argv && argv[0]) { argc = strlen (format); @@ -368,8 +367,6 @@ weechat_python_exec (struct t_plugin_script *script, rc = PyObject_CallFunction (evFunc, NULL); } - ret_value = NULL; - /* * ugly hack : rc = NULL while 'return weechat.WEECHAT_RC_OK .... * because of '#define WEECHAT_RC_OK 0' @@ -428,6 +425,7 @@ weechat_python_exec (struct t_plugin_script *script, /* PyEval_ReleaseThread (python_current_script->interpreter); */ +end: python_current_script = old_python_current_script; if (old_interpreter)