Skip to content

Commit

Permalink
use PY_SSIZE_T_CLEAN (#360)
Browse files Browse the repository at this point in the history
Fixes #359
  • Loading branch information
methane committed Jun 8, 2019
1 parent 3d046ad commit 6f5f48b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions MySQLdb/_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ PERFORMANCE OF THIS SOFTWARE.
#define my_bool _Bool
#endif

#define PY_SSIZE_T_CLEAN 1
#include "Python.h"
#if PY_MAJOR_VERSION >= 3
#define IS_PY3K
Expand Down Expand Up @@ -882,7 +883,8 @@ _mysql_escape_string(
{
PyObject *str;
char *in, *out;
int len, size;
int len;
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "s#:escape_string", &in, &size)) return NULL;
str = PyBytes_FromStringAndSize((char *) NULL, size*2+1);
if (!str) return PyErr_NoMemory();
Expand Down Expand Up @@ -1102,7 +1104,7 @@ static PyObject *
_mysql_field_to_python(
PyObject *converter,
const char *rowitem,
unsigned long length,
Py_ssize_t length,
MYSQL_FIELD *field,
const char *encoding)
{
Expand Down Expand Up @@ -1157,10 +1159,10 @@ _mysql_field_to_python(
}
return PyObject_CallFunction(converter,
binary ? "y#" : "s#",
rowitem, (int)length);
rowitem, (Py_ssize_t)length);
#else
return PyObject_CallFunction(converter,
"s#", rowitem, (int)length);
"s#", rowitem, (Py_ssize_t)length);
#endif
}

Expand Down Expand Up @@ -1752,7 +1754,8 @@ _mysql_ConnectionObject_query(
PyObject *args)
{
char *query;
int len, r;
Py_ssize_t len;
int r;
if (!PyArg_ParseTuple(args, "s#:query", &query, &len)) return NULL;
check_connection(self);

Expand All @@ -1774,7 +1777,8 @@ _mysql_ConnectionObject_send_query(
PyObject *args)
{
char *query;
int len, r;
Py_ssize_t len;
int r;
MYSQL *mysql = &(self->connection);
if (!PyArg_ParseTuple(args, "s#:query", &query, &len)) return NULL;
check_connection(self);
Expand Down

0 comments on commit 6f5f48b

Please sign in to comment.