Stricter use of PyArg_ParseTuple typed objects

The function expect PyObject *, not subclasses.
This commit is contained in:
Daniele Varrazzo 2018-12-27 23:46:49 +01:00
parent 3e66022912
commit 79de02d7d5
2 changed files with 12 additions and 7 deletions

View File

@ -113,14 +113,14 @@ qstring_str(qstringObject *self)
static PyObject *
qstring_prepare(qstringObject *self, PyObject *args)
{
connectionObject *conn;
PyObject *conn;
if (!PyArg_ParseTuple(args, "O!", &connectionType, &conn))
return NULL;
Py_CLEAR(self->conn);
Py_INCREF(conn);
self->conn = conn;
self->conn = (connectionObject *)conn;
Py_RETURN_NONE;
}

View File

@ -58,12 +58,17 @@ replmsg_repr(replicationMessageObject *self)
static int
replmsg_init(PyObject *obj, PyObject *args, PyObject *kwargs)
{
replicationMessageObject *self = (replicationMessageObject*) obj;
PyObject *cur = NULL;
replicationMessageObject *self = (replicationMessageObject *)obj;
if (!PyArg_ParseTuple(args, "O!O", &cursorType, &self->cursor, &self->payload))
if (!PyArg_ParseTuple(
args, "O!O", &cursorType, &cur, &self->payload)) {
return -1;
Py_XINCREF(self->cursor);
Py_XINCREF(self->payload);
}
Py_INCREF(cur);
self->cursor = (cursorObject *)cur;
Py_INCREF(self->payload);
self->data_size = 0;
self->data_start = 0;
@ -76,7 +81,7 @@ replmsg_init(PyObject *obj, PyObject *args, PyObject *kwargs)
static int
replmsg_traverse(replicationMessageObject *self, visitproc visit, void *arg)
{
Py_VISIT((PyObject* )self->cursor);
Py_VISIT((PyObject *)self->cursor);
Py_VISIT(self->payload);
return 0;
}