kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 0549295f30008897a95e1d2e034459dc39b0491a
parent c36a7759f11782f6e1d7cb9b84d5d6d5f1460c9e
Author: Joris Vink <joris@coders.se>
Date:   Thu, 28 Jan 2021 13:34:43 +0100

Cleanup integer types for # Python arguments.

Define PY_SSIZE_T_CLEAN before pulling in Python.h

Diffstat:
include/kore/python_api.h | 2++
src/python.c | 20++++++--------------
2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/include/kore/python_api.h b/include/kore/python_api.h @@ -21,6 +21,8 @@ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE +#define PY_SSIZE_T_CLEAN 1 + #include <Python.h> #include <frameobject.h> diff --git a/src/python.c b/src/python.c @@ -4552,12 +4552,7 @@ pyhttp_body_read(struct pyhttp_request *pyreq, PyObject *args) return (NULL); } - if (ret > INT_MAX) { - PyErr_SetString(PyExc_RuntimeError, "ret > INT_MAX"); - return (NULL); - } - - result = Py_BuildValue("ny#", ret, buf, (int)ret); + result = Py_BuildValue("ny#", ret, buf, ret); if (result == NULL) return (PyErr_NoMemory()); @@ -4676,12 +4671,7 @@ pyhttp_file_read(struct pyhttp_file *pyfile, PyObject *args) return (NULL); } - if (ret > INT_MAX) { - PyErr_SetString(PyExc_RuntimeError, "ret > INT_MAX"); - return (NULL); - } - - result = Py_BuildValue("ny#", ret, buf, (int)ret); + result = Py_BuildValue("ny#", ret, buf, ret); if (result == NULL) return (PyErr_NoMemory()); @@ -4725,8 +4715,9 @@ pyhttp_websocket_handshake(struct pyhttp_request *pyreq, PyObject *args) static PyObject * pyconnection_websocket_send(struct pyconnection *pyc, PyObject *args) { + int op; + ssize_t len; const char *data; - int op, len; if (pyc->c->proto != CONN_PROTO_WEBSOCKET) { PyErr_SetString(PyExc_TypeError, "not a websocket connection"); @@ -4761,10 +4752,11 @@ static PyObject * python_websocket_broadcast(PyObject *self, PyObject *args) { struct connection *c; + ssize_t len; struct pyconnection *pyc; const char *data; PyObject *pysrc; - int op, broadcast, len; + int op, broadcast; len = -1;