#20025: Do something for MySQL under Python 3
---------------------------------+-------------------------------------
     Reporter:  aaugustin        |                    Owner:  aaugustin
         Type:  Bug              |                   Status:  assigned
    Component:  Python 3         |                  Version:  master
     Severity:  Release blocker  |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  1                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  1
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+-------------------------------------

Comment (by aaugustin):

 This change helps a bit (thanks Claude for spotting the bug):

 {{{
 --- a/MySQLdb/__init__.py
 +++ b/MySQLdb/__init__.py
 @@ -73,7 +73,7 @@ def test_DBAPISet_set_inequality_membership():
      assert FIELD_TYPE.DATE != STRING

  def Binary(x):
 -    return str(x)
 +    return bytes(x)

  def Connect(*args, **kwargs):
      """Factory function for connections.Connection."""
 }}}

 But then another exceptions occurs because MySQL-for-Python-3 assumes that
 all bytestrings can and should be utf-8 decoded (the point of the `str`
 refactor in Python 3 is to forbid this):

 {{{
 ======================================================================
 ERROR: test_set_and_retrieve (model_fields.tests.BinaryFieldTests)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/Users/myk/Documents/dev/django/tests/model_fields/tests.py", line
 448, in test_set_and_retrieve
     dm.save()
   File "/Users/myk/Documents/dev/django/django/db/models/base.py", line
 548, in save
     force_update=force_update, update_fields=update_fields)
   File "/Users/myk/Documents/dev/django/django/db/models/base.py", line
 576, in save_base
     updated = self._save_table(raw, cls, force_insert, force_update,
 using, update_fields)
   File "/Users/myk/Documents/dev/django/django/db/models/base.py", line
 663, in _save_table
     result = self._do_insert(cls._base_manager, using, fields, update_pk,
 raw)
   File "/Users/myk/Documents/dev/django/django/db/models/base.py", line
 682, in _do_insert
     using=using, raw=raw)
   File "/Users/myk/Documents/dev/django/django/db/models/manager.py", line
 226, in _insert
     return insert_query(self.model, objs, fields, **kwargs)
   File "/Users/myk/Documents/dev/django/django/db/models/query.py", line
 1580, in insert_query
     return query.get_compiler(using=using).execute_sql(return_id)
   File "/Users/myk/Documents/dev/django/django/db/models/sql/compiler.py",
 line 884, in execute_sql
     cursor.execute(sql, params)
   File "/Users/myk/Documents/dev/django/django/db/utils.py", line 105, in
 inner
     return func(*args, **kwargs)
   File "/Users/myk/Documents/dev/django/django/db/backends/mysql/base.py",
 line 124, in execute
     return self.cursor.execute(query, args)
   File "/Users/myk/Documents/dev/MySQL-for-Python-3/mysql-
 py3/lib/python3.3/site-
 packages/MySQL_python-1.2.3-py3.3-macosx-10.8-x86_64.egg/MySQLdb/cursors.py",
 line 160, in execute
     query = query % db.literal(args)
   File "/Users/myk/Documents/dev/MySQL-for-Python-3/mysql-
 py3/lib/python3.3/site-
 
packages/MySQL_python-1.2.3-py3.3-macosx-10.8-x86_64.egg/MySQLdb/connections.py",
 line 241, in literal
     return self.escape(o, self.encoders)
   File "/Users/myk/Documents/dev/MySQL-for-Python-3/mysql-
 py3/lib/python3.3/site-
 
packages/MySQL_python-1.2.3-py3.3-macosx-10.8-x86_64.egg/MySQLdb/connections.py",
 line 190, in bytes_literal
     return db.literal(u.decode(bytes_literal.charset))
 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfe in position 2:
 invalid start byte
 }}}

 I'm starting to doubt the quality of this port. Either no one's using
 MySQL on Python 3 besides toy projects, or I haven't found the library
 they're using :/

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20025#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to