Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6f5f48b

Browse filesBrowse files
authored
use PY_SSIZE_T_CLEAN (PyMySQL#360)
Fixes PyMySQL#359
1 parent 3d046ad commit 6f5f48b
Copy full SHA for 6f5f48b

File tree

Expand file treeCollapse file tree

1 file changed

+10
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-6
lines changed

‎MySQLdb/_mysql.c

Copy file name to clipboardExpand all lines: MySQLdb/_mysql.c
+10-6Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ PERFORMANCE OF THIS SOFTWARE.
3434
#define my_bool _Bool
3535
#endif
3636

37+
#define PY_SSIZE_T_CLEAN 1
3738
#include "Python.h"
3839
#if PY_MAJOR_VERSION >= 3
3940
#define IS_PY3K
@@ -882,7 +883,8 @@ _mysql_escape_string(
882883
{
883884
PyObject *str;
884885
char *in, *out;
885-
int len, size;
886+
int len;
887+
Py_ssize_t size;
886888
if (!PyArg_ParseTuple(args, "s#:escape_string", &in, &size)) return NULL;
887889
str = PyBytes_FromStringAndSize((char *) NULL, size*2+1);
888890
if (!str) return PyErr_NoMemory();
@@ -1102,7 +1104,7 @@ static PyObject *
11021104
_mysql_field_to_python(
11031105
PyObject *converter,
11041106
const char *rowitem,
1105-
unsigned long length,
1107+
Py_ssize_t length,
11061108
MYSQL_FIELD *field,
11071109
const char *encoding)
11081110
{
@@ -1157,10 +1159,10 @@ _mysql_field_to_python(
11571159
}
11581160
return PyObject_CallFunction(converter,
11591161
binary ? "y#" : "s#",
1160-
rowitem, (int)length);
1162+
rowitem, (Py_ssize_t)length);
11611163
#else
11621164
return PyObject_CallFunction(converter,
1163-
"s#", rowitem, (int)length);
1165+
"s#", rowitem, (Py_ssize_t)length);
11641166
#endif
11651167
}
11661168

@@ -1752,7 +1754,8 @@ _mysql_ConnectionObject_query(
17521754
PyObject *args)
17531755
{
17541756
char *query;
1755-
int len, r;
1757+
Py_ssize_t len;
1758+
int r;
17561759
if (!PyArg_ParseTuple(args, "s#:query", &query, &len)) return NULL;
17571760
check_connection(self);
17581761

@@ -1774,7 +1777,8 @@ _mysql_ConnectionObject_send_query(
17741777
PyObject *args)
17751778
{
17761779
char *query;
1777-
int len, r;
1780+
Py_ssize_t len;
1781+
int r;
17781782
MYSQL *mysql = &(self->connection);
17791783
if (!PyArg_ParseTuple(args, "s#:query", &query, &len)) return NULL;
17801784
check_connection(self);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.