Skip to content

Commit

Permalink
Fix for CONPY-131:
Browse files Browse the repository at this point in the history
Instead of using PyStructSequence_New (broken in Python3.6) use a
static struct which will be initialized voa PyStructSequence_Init()
call.
  • Loading branch information
9EOR9 committed Nov 16, 2020
1 parent 37864dd commit f6be6ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/mariadb_python.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ typedef struct {
unsigned long statement_len;
PyObject **values;
PyStructSequence_Field *sequence_fields;
PyTypeObject *sequence_type;
PyTypeObject sequence_type;
unsigned long prefetch_rows;
unsigned long cursor_type;
int64_t affected_rows;
Expand Down
5 changes: 2 additions & 3 deletions mariadb/mariadb_cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ void MrdbCursor_clear(MrdbCursor *self, uint8_t new_stmt)
if (self->sequence_fields)
{
MARIADB_FREE_MEM(self->sequence_fields);
Py_DECREF((PyObject *)self->sequence_type);
}
self->fields= NULL;
self->row_count= 0;
Expand Down Expand Up @@ -573,7 +572,7 @@ static int Mrdb_GetFieldInfo(MrdbCursor *self)
{
self->sequence_fields[i].name= self->fields[i].name;
}
self->sequence_type= PyStructSequence_NewType(&sequence_desc);
(void)PyStructSequence_InitType(&self->sequence_type, &sequence_desc);
}
}
return 0;
Expand Down Expand Up @@ -1181,7 +1180,7 @@ mariadb_get_sequence_or_tuple(MrdbCursor *self)
switch (self->result_format)
{
case RESULT_NAMED_TUPLE:
return PyStructSequence_New(self->sequence_type);
return PyStructSequence_New(&self->sequence_type);
case RESULT_DICTIONARY:
return PyDict_New();
default:
Expand Down

0 comments on commit f6be6ba

Please sign in to comment.