1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-24 11:56:38 +02:00

python: fix read of return value for callbacks returning an integer in Python 2.x (closes #125)

This commit is contained in:
Sébastien Helleu
2014-07-12 14:51:39 +02:00
parent c5710c6f24
commit 3ec3fb4e8d
3 changed files with 12 additions and 2 deletions
+2 -2
View File
@@ -391,11 +391,11 @@ weechat_python_exec (struct t_plugin_script *script,
ret_value = NULL;
Py_XDECREF(rc);
}
else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (PyLong_Check (rc)))
else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (PY_INTEGER_CHECK(rc)))
{
ret_int = malloc (sizeof (*ret_int));
if (ret_int)
*ret_int = (int) PyLong_AsLong(rc);
*ret_int = (int) PyLong_AsLong (rc);
ret_value = ret_int;
Py_XDECREF(rc);
}
+8
View File
@@ -34,6 +34,14 @@
#define PyUnicode_FromString PyString_FromString
#endif
#if PY_MAJOR_VERSION >= 3
/* check of integer with Python >= 3.x */
#define PY_INTEGER_CHECK(x) (PyLong_Check(x))
#else
/* check of integer with Python <= 2.x */
#define PY_INTEGER_CHECK(x) (PyInt_Check(x) || PyLong_Check(x))
#endif
extern struct t_weechat_plugin *weechat_python_plugin;
extern int python_quiet;