Opened 12 years ago

Closed 10 years ago

#20377 closed Cleanup/optimization (fixed)

BinaryField doesn't work on MySQL and Python 3

Reported by: Aymeric Augustin Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Aymeric Augustin)

An unofficial port of MySQLdb appears to be the only solution to connect to MySQL from Python 3 at this time, see [e81e319f].

Unfortunately, its handling of binary data is very buggy. For instance, this code is almost certainly wrong:

def Binary(x):
    return str(x)

There are other problems, like attempting to decode all bytestrings as UTF-8.

With no short-term solution in sight, tests involving BinaryField were marked as expected failures on MySQL and Python 3 in [7476d96f].

This commit should be reverted once a production-grade, Python 3-compatible database adapter exists for MySQL.

Change History (7)

comment:1 by Aymeric Augustin, 12 years ago

Description: modified (diff)

comment:2 by Aymeric Augustin, 12 years ago

Triage Stage: AcceptedSomeday/Maybe

comment:3 by Claude Paroz, 12 years ago

FWIW, I also tested this with PyMySQL (branch here: https://github.com/claudep/django/tree/pymysql) and it suffers from the exact same issue.
See also https://github.com/petehunt/PyMySQL/issues/142

comment:4 by Aymeric Augustin, 12 years ago

Regarding MySQLdb, I haven't reported this bug upstream, because I don't even where to report it, given the current fragmentation.

comment:5 by Aymeric Augustin, 11 years ago

The solution may be #12500: Support for MySQL Connector/Python.

comment:6 by Claude Paroz <claude@…>, 10 years ago

In 68a439a18da17a65555832eff0a7c2090655b583:

Removed supports_binary_field flag as all backends support them

It was mainly for MySQL on Python 3, but now the current
recommended MySQL driver for Python 3 (mysqlclient) does support
binary fields, it is unneeded. Refs #20377.

comment:7 by Claude Paroz, 10 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top