Bug #99757 convert_to_mysql method get exception Failed converting Python 'str'
Submitted: 2 Jun 2020 7:43 Modified: 11 May 17:40
Reporter: Noam Baron Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:8.0.20 OS:Linux
Assigned to: CPU Architecture:Any
Tags: convert_to_mysql

[2 Jun 2020 7:43] Noam Baron
Description:
I'm running the following script in a linux server:

******************************************
import _mysql_connector

ccnx = _mysql_connector.MySQL()
ccnx.connect(user=<user_name>, database=<db_name>, password=<pass>, host=<host>)
bad_str = 'just_an_��_example'

try:
    str_converted = ccnx.convert_to_mysql(*[bad_str])
    print('str converted is %s', str_converted)
except Exception as e:
    print('cant convert bad str %s',bad_str)
    print(e)

******************************************

The script get exception "Failed converting Python 'str'".

I've tried to add encoding exports before running the script:

export LC_ALL=en_US.utf-8
export LANG=en_US.utf-8
It didn't work as well..

How to repeat:
run the script using your db info
[2 Jun 2020 10:38] MySQL Verification Team
Hello Noam Baron,

Thank you for the report and test case.

regards,
Umesh
[2 Jun 2020 10:39] MySQL Verification Team
Workaround is to set ccnx.set_character_set('utf8')
[11 May 17:40] Philip Olson
It appears this bug report was lost/forgotten over time (we're sorry!), but the associated bug contains "This has been fixed, could not reproduce on 8.0.23" from a developer. It's unclear when this was fixed. Setting status to closed.