summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/python/weechat-python.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-02-20 10:01:47 +0100
committerSebastien Helleu <flashcode@flashtux.org>2009-02-20 10:01:47 +0100
commita3b9fa248340c94b1d15abafd521c4f759433dd4 (patch)
tree5d99fc3c88bc63066efda51ca487b560a56244f8 /src/plugins/scripts/python/weechat-python.c
parente7589e732bfda17608428fd6b1c0cfa4f8ee3150 (diff)
downloadweechat-a3b9fa248340c94b1d15abafd521c4f759433dd4.zip
Fix crash in python plugin when callbacks are called during script initialization
Diffstat (limited to 'src/plugins/scripts/python/weechat-python.c')
-rw-r--r--src/plugins/scripts/python/weechat-python.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c
index 07f4d49b8..fd4c68ffa 100644
--- a/src/plugins/scripts/python/weechat-python.c
+++ b/src/plugins/scripts/python/weechat-python.c
@@ -60,10 +60,10 @@ weechat_python_exec (struct t_plugin_script *script,
PyObject *rc;
void *ret_value;
int *ret_i;
- struct t_plugin_script *old_python_current_script;
/* PyEval_AcquireLock (); */
- PyThreadState_Swap (script->interpreter);
+ if (script->interpreter)
+ PyThreadState_Swap (script->interpreter);
evMain = PyImport_AddModule ((char *) "__main__");
evDict = PyModule_GetDict (evMain);
@@ -77,8 +77,7 @@ weechat_python_exec (struct t_plugin_script *script,
/* PyEval_ReleaseThread (python_current_script->interpreter); */
return NULL;
}
-
- old_python_current_script = python_current_script;
+
python_current_script = script;
if (argv && argv[0])
@@ -173,9 +172,6 @@ weechat_python_exec (struct t_plugin_script *script,
"a valid value"),
weechat_prefix ("error"), PYTHON_PLUGIN_NAME, function);
/* PyEval_ReleaseThread (python_current_script->interpreter); */
- python_current_script = old_python_current_script;
- if (python_current_script)
- PyThreadState_Swap (python_current_script->interpreter);
return NULL;
}
@@ -186,9 +182,6 @@ weechat_python_exec (struct t_plugin_script *script,
"function \"%s\""),
weechat_prefix ("error"), PYTHON_PLUGIN_NAME, function);
/* PyEval_ReleaseThread (python_current_script->interpreter); */
- python_current_script = old_python_current_script;
- if (python_current_script)
- PyThreadState_Swap (python_current_script->interpreter);
return NULL;
}
@@ -197,10 +190,6 @@ weechat_python_exec (struct t_plugin_script *script,
/* PyEval_ReleaseThread (python_current_script->interpreter); */
- python_current_script = old_python_current_script;
- if (python_current_script)
- PyThreadState_Swap (python_current_script->interpreter);
-
return ret_value;
}
@@ -315,7 +304,7 @@ weechat_python_load (const char *filename)
return 0;
}
- /* PyThreadState_Swap (python_current_interpreter); */
+ PyThreadState_Swap (python_current_interpreter);
weechat_module = Py_InitModule ("weechat", weechat_python_funcs);