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
Note: See
TracTickets for help on using
tickets.


