Edgewall Software
Modify

Opened 12 years ago

Closed 12 years ago

#7849 closed defect (invalid)

MySQLUnicodeCursor fails on blob data

Reported by: dalius@… Owned by:
Priority: high Milestone:
Component: general Version: 0.11.2.1
Severity: normal Keywords: mysql
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I have upgraded to trac 0.11.2.1 and my AuthOpenIdPlugin stopped to work (http://trac.sandbox.lt/auth/wiki/AuthOpenIdPlugin).

After little analysis I have found that problem is in trac's mysql_backend: http://svn.edgewall.org/repos/trac/trunk/trac/db/mysql_backend.py

The problem is that it tries to decode BLOB data column and naturally fails to do that.

I am using following fix at this moment (but I'm not satisfied with it):

    class MySQLUnicodeCursor(MySQLdb.cursors.Cursor):

        def _try_to_decode(self, v):
            try:
                return v.decode('utf-8')
            except UnicodeDecodeError:
                return v

        def _convert_row(self, row):
            return tuple([(isinstance(v, str) and [self._try_to_decode(v)] or [v])[0]
                          for v in row])

Attachments (0)

Change History (1)

comment:1 by dalius@…, 12 years ago

Resolution: invalid
Status: newclosed

I have decided to use MySql connection directly at that worked (I mean .cnx.cnx).

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.