mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-10-27 04:55:04 +03:00
Convert python/libxml.c to PY_SSIZE_T_CLEAN
Define PY_SSIZE_T_CLEAN macro in python/libxml.c and cast the string length (int len) explicitly to Py_ssize_t when passing a string to a function call using PyObject_CallMethod() with the "s#" format.
This commit is contained in:
parent
f42a0524c6
commit
ac5e99911a
@ -11,6 +11,7 @@
|
||||
*
|
||||
* daniel@veillard.com
|
||||
*/
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include <Python.h>
|
||||
#include <fileobject.h>
|
||||
/* #include "config.h" */
|
||||
@ -1048,10 +1049,10 @@ pythonCharacters(void *user_data, const xmlChar * ch, int len)
|
||||
if (type != 0) {
|
||||
if (type == 1)
|
||||
result = PyObject_CallMethod(handler, (char *) "characters",
|
||||
(char *) "s#", ch, len);
|
||||
(char *) "s#", ch, (Py_ssize_t)len);
|
||||
else if (type == 2)
|
||||
result = PyObject_CallMethod(handler, (char *) "data",
|
||||
(char *) "s#", ch, len);
|
||||
(char *) "s#", ch, (Py_ssize_t)len);
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_XDECREF(result);
|
||||
@ -1078,11 +1079,11 @@ pythonIgnorableWhitespace(void *user_data, const xmlChar * ch, int len)
|
||||
result =
|
||||
PyObject_CallMethod(handler,
|
||||
(char *) "ignorableWhitespace",
|
||||
(char *) "s#", ch, len);
|
||||
(char *) "s#", ch, (Py_ssize_t)len);
|
||||
else if (type == 2)
|
||||
result =
|
||||
PyObject_CallMethod(handler, (char *) "data",
|
||||
(char *) "s#", ch, len);
|
||||
(char *) "s#", ch, (Py_ssize_t)len);
|
||||
Py_XDECREF(result);
|
||||
}
|
||||
}
|
||||
@ -1223,11 +1224,11 @@ pythonCdataBlock(void *user_data, const xmlChar * ch, int len)
|
||||
if (type == 1)
|
||||
result =
|
||||
PyObject_CallMethod(handler, (char *) "cdataBlock",
|
||||
(char *) "s#", ch, len);
|
||||
(char *) "s#", ch, (Py_ssize_t)len);
|
||||
else if (type == 2)
|
||||
result =
|
||||
PyObject_CallMethod(handler, (char *) "cdata",
|
||||
(char *) "s#", ch, len);
|
||||
(char *) "s#", ch, (Py_ssize_t)len);
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_XDECREF(result);
|
||||
|
Loading…
Reference in New Issue
Block a user