Skip to content
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

ignore the UnicodeDecodeError when some bytes cannot be decoded with … #582

Closed
wants to merge 1 commit into from

Conversation

wzzz
Copy link

@wzzz wzzz commented Apr 21, 2023

sometime the function cursor.fetchall() raise exceptions like follower:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 0: invalid continuation byte

this exception is very annoying if you don't fix the records which include the Garbled character.

…the specified charset

use env variable MYC_USE_DECODE_ERR_REP_MODE to switch on/off, if MYC_USE_DECODE_ERR_REP_MODE is 1, then use replace mode, or NULL mode
@wzzz wzzz closed this Apr 21, 2023
if (encoding == utf8) {
//fprintf(stderr, "decoding with utf8!\n");
return PyUnicode_DecodeUTF8(rowitem, length, NULL);
return PyUnicode_DecodeUTF8(rowitem, length, decode_err_mode);

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
} else {
//fprintf(stderr, "decoding with %s\n", encoding);
return PyUnicode_Decode(rowitem, length, encoding, NULL);
return PyUnicode_Decode(rowitem, length, encoding, decode_err_mode);

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
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.

1 participant