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

Conversation

fried
Copy link
Contributor

@fried fried commented Mar 23, 2019

… about encoding of unknown fields for python3

Before Most string fields were passed to custom converter functions as "bytes",
everything else was assumed to be valid encoded utf-8 and passed as str.
This could cause issues where some unknown field was not valid utf-8 and
a decode error is triggered where it can't be fixed or avoided by the
end user.

Instead we should short list those fields that we know for sure have to
be str type because the existing converters expect it to be that way.
So all the date conversions, and (NEW)DECIMAL since the python decimal
type will not accept bytes object.

Everything else stays bytes, which is the least suprising and safest
thing to do.

… about encoding of

unknown fields for python3

Before *Most* string fields were passed to custom converter functions as "bytes",
everything else was assumed to be valid encoded utf-8 and passed as str.
This could cause issues where some unknown field was not valid utf-8 and
a decode error is triggered where it can't be fixed or avoided by the
end user.

Instead we should short list those fields that we know for sure have to
be str type because the existing converters expect it to be that way.
So all the date conversions, and (NEW)DECIMAL since the python decimal
type will not accept bytes object.

Everything else stays bytes, which is the least suprising and safest
thing to do.
@fried
Copy link
Contributor Author

fried commented Mar 23, 2019

I'm syncing up the internal fork of mysqlclient-python and after 5 years there are some local changes that should be upstreamed so I'm sorry if i'm overloading you with pull requests.

@PyMySQL PyMySQL deleted a comment from codecov bot Jul 31, 2019
@PyMySQL PyMySQL deleted a comment from codecov bot Jul 31, 2019
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.

@methane methane added this to the v2.0 milestone Nov 18, 2019
@methane methane merged commit 3fb4eb1 into PyMySQL:master Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants