Modify ↓
Opened 16 years ago
Closed 16 years ago
#7849 closed defect (invalid)
MySQLUnicodeCursor fails on blob data
Reported by: | 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)
Note:
See TracTickets
for help on using tickets.
I have decided to use MySql connection directly at that worked (I mean .cnx.cnx).