diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index 4e50072a7..8f024fde4 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -91,14 +91,20 @@ weechat_python_exec (t_weechat_plugin *plugin, else rc = PyObject_CallFunction (evFunc, ""); + + if (rc == Py_None) + { + python_plugin->print_server (python_plugin, "Python error: function \"%s\" must return a valid value", function); + return PLUGIN_RC_OK; + } + if (rc) { ret = (int) PyInt_AsLong(rc); Py_XDECREF(rc); } - if (PyErr_Occurred ()) - PyErr_Print (); + if (PyErr_Occurred ()) PyErr_Print (); if (ret < 0) return PLUGIN_RC_OK; diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index 8a35cbf5a..6e0767f6b 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -153,6 +153,12 @@ weechat_ruby_exec (t_weechat_plugin *plugin, return PLUGIN_RC_KO; } + + if (ruby_retcode == Qnil) + { + ruby_plugin->print_server (ruby_plugin, "Ruby error: function \"%s\" must return a valid value", function); + return PLUGIN_RC_OK; + } return NUM2INT(ruby_retcode); } diff --git a/weechat/src/plugins/scripts/python/weechat-python.c b/weechat/src/plugins/scripts/python/weechat-python.c index 4e50072a7..8f024fde4 100644 --- a/weechat/src/plugins/scripts/python/weechat-python.c +++ b/weechat/src/plugins/scripts/python/weechat-python.c @@ -91,14 +91,20 @@ weechat_python_exec (t_weechat_plugin *plugin, else rc = PyObject_CallFunction (evFunc, ""); + + if (rc == Py_None) + { + python_plugin->print_server (python_plugin, "Python error: function \"%s\" must return a valid value", function); + return PLUGIN_RC_OK; + } + if (rc) { ret = (int) PyInt_AsLong(rc); Py_XDECREF(rc); } - if (PyErr_Occurred ()) - PyErr_Print (); + if (PyErr_Occurred ()) PyErr_Print (); if (ret < 0) return PLUGIN_RC_OK; diff --git a/weechat/src/plugins/scripts/ruby/weechat-ruby.c b/weechat/src/plugins/scripts/ruby/weechat-ruby.c index 8a35cbf5a..6e0767f6b 100644 --- a/weechat/src/plugins/scripts/ruby/weechat-ruby.c +++ b/weechat/src/plugins/scripts/ruby/weechat-ruby.c @@ -153,6 +153,12 @@ weechat_ruby_exec (t_weechat_plugin *plugin, return PLUGIN_RC_KO; } + + if (ruby_retcode == Qnil) + { + ruby_plugin->print_server (ruby_plugin, "Ruby error: function \"%s\" must return a valid value", function); + return PLUGIN_RC_OK; + } return NUM2INT(ruby_retcode); }