← Back to team overview

holland-coredev team mailing list archive

[Bug 1076033] Re: Broken handling of unicode in mysql credentials

 

This was partially addressed in 1.0.8.  There are several bugs where
MySQLdb does not handle unicode names in some of the auth credentials
correctly, still, but we should handle many more cases at this point.
Long-term we will likely move away from MySQLdb entirely as other
options become more mature and accessible.

** Changed in: holland-backup
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Holland
Build, which is subscribed to holland-backup.
https://bugs.launchpad.net/bugs/1076033

Title:
  Broken handling of unicode in mysql credentials

Status in Holland Backup Framework:
  Fix Released

Bug description:
  If characters outside of ascii are in MySQL credentials, holland will
  fail with a UnicodeEncodeError.

  This happens in two places:

  * holland's parsing of my.cnf files has a few places where it incorrectly uses 'str(value)'
  * holland type conversion for 'port' -> int had a hack 'str(value)' fallback.

  Further, there is a bug in the required upstream MySQL connector,
  MySQLdb that will fail as well, if you pass a unicode passwd keyword:

  >>> import MySQLdb
  >>> MySQLdb.connect(passwd=u'пароль', charset='utf8')
  Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "/usr/lib64/python2.4/site-packages/MySQLdb/__init__.py", line 75, in Connect
      return Connection(*args, **kwargs)
    File "/usr/lib64/python2.4/site-packages/MySQLdb/connections.py", line 164, in __init__
      super(Connection, self).__init__(*args, **kwargs2)
  UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)

  This is actually broken in most python/mysql connectors including
  mysql-connector-python and oursql, so a potential connector bug in the
  future.

  I think the correct behavior here is to encode to 'utf8' bytes first
  before passing to the underlying connector.  Alternatively, with
  libmysqlclient, just generating a valid my.cnf should be handled
  properly, so long as holland handles unicode properly.

To manage notifications about this bug go to:
https://bugs.launchpad.net/holland-backup/+bug/1076033/+subscriptions


References