summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/python
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/scripts/python')
-rw-r--r--src/plugins/scripts/python/weechat-python-api.c2
-rw-r--r--src/plugins/scripts/python/weechat-python.c8
-rw-r--r--src/plugins/scripts/python/weechat-python.h1
3 files changed, 8 insertions, 3 deletions
diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c
index 18edfb334..8c98a99b4 100644
--- a/src/plugins/scripts/python/weechat-python-api.c
+++ b/src/plugins/scripts/python/weechat-python-api.c
@@ -66,6 +66,7 @@ weechat_python_api_register (PyObject *self, PyObject *args)
(void) self;
python_current_script = NULL;
+ python_registered_script = NULL;
name = NULL;
author = NULL;
@@ -102,6 +103,7 @@ weechat_python_api_register (PyObject *self, PyObject *args)
description, shutdown_func, charset);
if (python_current_script)
{
+ python_registered_script = python_current_script;
if ((weechat_python_plugin->debug >= 1) || !python_quiet)
{
weechat_printf (NULL,
diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c
index 55e1be01e..e16618612 100644
--- a/src/plugins/scripts/python/weechat-python.c
+++ b/src/plugins/scripts/python/weechat-python.c
@@ -41,6 +41,7 @@ int python_quiet;
struct t_plugin_script *python_scripts = NULL;
struct t_plugin_script *last_python_script = NULL;
struct t_plugin_script *python_current_script = NULL;
+struct t_plugin_script *python_registered_script = NULL;
const char *python_current_script_filename = NULL;
PyThreadState *python_mainThreadState = NULL;
@@ -228,8 +229,7 @@ weechat_python_exec (struct t_plugin_script *script,
/* PyEval_ReleaseThread (python_current_script->interpreter); */
- if (old_python_current_script)
- python_current_script = old_python_current_script;
+ python_current_script = old_python_current_script;
if (old_interpreter)
PyThreadState_Swap (old_interpreter);
@@ -335,6 +335,7 @@ weechat_python_load (const char *filename)
}
python_current_script = NULL;
+ python_registered_script = NULL;
/* PyEval_AcquireLock (); */
python_current_interpreter = Py_NewInterpreter ();
@@ -492,7 +493,7 @@ weechat_python_load (const char *filename)
fclose (fp);
- if (python_current_script == NULL)
+ if (!python_registered_script)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: function \"register\" not "
@@ -506,6 +507,7 @@ weechat_python_load (const char *filename)
return 0;
}
+ python_current_script = python_registered_script;
python_current_script->interpreter = (PyThreadState *) python_current_interpreter;
/* PyEval_ReleaseThread (python_current_script->interpreter); */
diff --git a/src/plugins/scripts/python/weechat-python.h b/src/plugins/scripts/python/weechat-python.h
index 8c460b79e..421f73b6b 100644
--- a/src/plugins/scripts/python/weechat-python.h
+++ b/src/plugins/scripts/python/weechat-python.h
@@ -31,6 +31,7 @@ extern int python_quiet;
extern struct t_plugin_script *python_scripts;
extern struct t_plugin_script *last_python_script;
extern struct t_plugin_script *python_current_script;
+extern struct t_plugin_script *python_registered_script;
extern const char *python_current_script_filename;
extern void *weechat_python_exec (struct t_plugin_script *script,