Edgewall Software

Ticket #7849 (new defect)

Opened 5 weeks ago

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:

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

Add/Change #7849 (MySQLUnicodeCursor fails on blob data)

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from (none). Next status will be 'new'
The owner will change from (none) to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.