Skip to content

Fixup _mysql.c custom converters binary switch statement to not guess… #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions MySQLdb/_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,25 +1132,16 @@ _mysql_field_to_python(
#ifdef IS_PY3K
int binary;
switch (field->type) {
case FIELD_TYPE_TINY_BLOB:
case FIELD_TYPE_MEDIUM_BLOB:
case FIELD_TYPE_LONG_BLOB:
case FIELD_TYPE_BLOB:
case FIELD_TYPE_VAR_STRING:
case FIELD_TYPE_STRING:
case FIELD_TYPE_GEOMETRY:
case FIELD_TYPE_BIT:
#ifdef FIELD_TYPE_JSON
case FIELD_TYPE_JSON:
#else
case 245: // JSON
#endif
// Call converter with bytes
binary = 1;
case FIELD_TYPE_DECIMAL:
case FIELD_TYPE_NEWDECIMAL:
case FIELD_TYPE_TIMESTAMP:
case FIELD_TYPE_DATETIME:
case FIELD_TYPE_TIME:
case FIELD_TYPE_DATE:
binary = 0; // pass str, because these converters expect it
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break;
default: // e.g. FIELD_TYPE_DATETIME, etc.
// Call converter with unicode string
binary = 0;
default: // Default to just passing bytes
binary = 1;
}
return PyObject_CallFunction(converter,
binary ? "y#" : "s#",
Expand Down