Bug 239381 - uncorrect handling of encoded strings in cursors.py
Summary: uncorrect handling of encoded strings in cursors.py
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: MySQL-python
Version: 4.5
Hardware: i386
OS: Linux
Target Milestone: ---
: ---
Assignee: Tom Lane
QA Contact: qe-baseos-daemons
URL: http://sourceforge.net/tracker/index....
Depends On:
TreeView+ depends on / blocked
Reported: 2007-05-08 00:42 UTC by ryo fujita
Modified: 2013-07-03 03:12 UTC (History)
1 user (show)

Clone Of:
Last Closed: 2012-06-20 15:53:27 UTC

Attachments (Terms of Use)
patch from http://sourceforge.net/tracker/index.php?func=detail&aid=1521274&group_id=22307&atid=374932 (1.55 KB, patch)
2007-05-08 00:42 UTC, ryo fujita
no flags Details | Diff

Description ryo fujita 2007-05-08 00:42:51 UTC
Description of problem:uncorrect handling of encoded strings in cursors.py

Version-Release number of selected component (if applicable): 1.2.1_p2-1.el4.1

How reproducible:run the script including utf-8 or other non ascii character set.

Steps to Reproduce:see below

#!/usr/bin/env python
# coding:utf-8

import MySQLdb

DB_Info = dict(host='localhost', user='root', passwd='pass', db='test', charset='utf8')
db = MySQLdb.connect(**DB_Info)
c = db.cursor(MySQLdb.cursors.DictCursor)
c.execute("INSERT INTO some_table (some_fld) VALUES ('%s')" % value_including_non_ascii)  

Actual results:Traceback occured with following messages

File "/usr/lib/python2.3/site-packages/MySQLdb/cursors.py", line 146, in execute
    query = query.encode(charset)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 108: ordinal not in range(128)

Expected results:"INSERT" SQL is done successful

Additional info:

Comment 2 Jiri Pallich 2012-06-20 15:53:27 UTC
Thank you for submitting this issue for consideration in Red Hat Enterprise Linux. The release for which you requested us to review is now End of Life. 
Please See https://access.redhat.com/support/policy/updates/errata/

If you would like Red Hat to re-consider your feature request for an active release, please re-open the request via appropriate support channels and provide additional supporting details about the importance of this issue.

Note You need to log in before you can comment on or make changes to this bug.