diff options
Diffstat (limited to 'plugins/python')
-rw-r--r-- | plugins/python/python.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/plugins/python/python.c b/plugins/python/python.c index 4ea34c23..d5a2aba8 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -88,8 +88,10 @@ #undef PyUnicode_Check #undef PyUnicode_FromString +#undef PyUnicode_FromFormat #define PyUnicode_Check PyString_Check #define PyUnicode_AsFormat PyString_AsFormat +#define PyUnicode_FromFormat PyString_FromFormat #define PyUnicode_FromString PyString_FromString #define PyUnicode_AsUTF8 PyString_AsString @@ -496,18 +498,20 @@ Callback_Command(char *word[], char *word_eol[], void *userdata) PyObject *retobj; PyObject *word_list, *word_eol_list; int ret = 0; + PyObject *plugin; - BEGIN_PLUGIN(hook->plugin); + plugin = hook->plugin; + BEGIN_PLUGIN(plugin); word_list = Util_BuildList(word+1); if (word_list == NULL) { - END_PLUGIN(hook->plugin); + END_PLUGIN(plugin); return 0; } word_eol_list = Util_BuildList(word_eol+1); if (word_eol_list == NULL) { Py_DECREF(word_list); - END_PLUGIN(hook->plugin); + END_PLUGIN(plugin); return 0; } @@ -526,7 +530,7 @@ Callback_Command(char *word[], char *word_eol[], void *userdata) PyErr_Print(); } - END_PLUGIN(hook->plugin); + END_PLUGIN(plugin); return ret; } @@ -546,6 +550,7 @@ Callback_Print(char *word[], void *userdata) int next = 0; int i; int ret = 0; + PyObject *plugin; /* Cut off the message identifier. */ word += 1; @@ -577,13 +582,14 @@ Callback_Print(char *word[], void *userdata) } word_eol[i] = ""; - BEGIN_PLUGIN(hook->plugin); + plugin = hook->plugin; + BEGIN_PLUGIN(plugin); word_list = Util_BuildList(word); if (word_list == NULL) { g_free(word_eol_raw); g_free(word_eol); - END_PLUGIN(hook->plugin); + END_PLUGIN(plugin); return 0; } word_eol_list = Util_BuildList(word_eol); @@ -591,7 +597,7 @@ Callback_Print(char *word[], void *userdata) g_free(word_eol_raw); g_free(word_eol); Py_DECREF(word_list); - END_PLUGIN(hook->plugin); + END_PLUGIN(plugin); return 0; } @@ -612,7 +618,7 @@ Callback_Print(char *word[], void *userdata) PyErr_Print(); } - END_PLUGIN(hook->plugin); + END_PLUGIN(plugin); return ret; } @@ -1502,7 +1508,10 @@ Module_hexchat_get_info(PyObject *self, PyObject *args) Py_INCREF(Py_None); return Py_None; } - return PyUnicode_FromString(info); + if (strcmp (name, "gtkwin_ptr") == 0) + return PyUnicode_FromFormat("%p", info); /* format as pointer */ + else + return PyUnicode_FromString(info); } static PyObject * @@ -2157,6 +2166,7 @@ IInterp_Exec(char *command) memcpy(buffer, command, len); buffer[len] = '\n'; buffer[len+1] = 0; + PyRun_SimpleString("import hexchat"); o = PyRun_StringFlags(buffer, Py_single_input, d, d, NULL); g_free(buffer); if (o == NULL) { |