Opened 12 years ago

Closed 8 years ago

#429 closed defect (wontfix)

charset error with mysql

Reported by: rguerra@… Owned by: Brad Anderson
Priority: highest Component: DbAuthPlugin
Severity: blocker Keywords:
Cc: Trac Release: 0.11

Description (last modified by Alec Thomas)

After installing dbauth on trac .10 dev and making the configuration changes suggested, I got the following error on logging on...

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/web/", line 313, in dispatch_request
  File "/usr/lib/python2.4/site-packages/trac/web/", line 183, in dispatch
    req.authname = self.authenticate(req)
  File "/usr/lib/python2.4/site-packages/trac/web/", line 143, in authenticate
    authname = authenticator.authenticate(req)
  File "build/bdist.linux-i686/egg/dbauth/", line 61, in authenticate
  File "build/bdist.linux-i686/egg/dbauth/", line 197, in _get_name_for_cookie
  File "build/bdist.linux-i686/egg/dbauth/", line 22, in get_db
  File "/usr/lib/python2.4/site-packages/trac/db/", line 71, in get_connection
    return self._cnx_pool.get_cnx()
  File "/usr/lib/python2.4/site-packages/trac/db/", line 75, in get_cnx
    cnx = self._connector.get_connection(**self._kwargs)
  File "/usr/lib/python2.4/site-packages/trac/db/", line 40, in get_connection
    return MySQLConnection(path, user, password, host, port, params)
  File "/usr/lib/python2.4/site-packages/trac/db/", line 117, in __init__
    port=port, use_unicode=True, charset='utf8')
  File "/usr/lib/python2.4/site-packages/MySQLdb/", line 66, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python2.4/site-packages/MySQLdb/", line 134, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
TypeError: 'charset' is an invalid keyword argument for this function

Noticing the charset error, I tried the following which resolved the error and allowed me to login using the creditials in the mysql database

removing the reference to 'charset" in /usr/lib/python2.4/site-packages/trac/db/

        cnx = MySQLdb.connect(db=path, user=user, passwd=password, host=host,
                              port=port, use_unicode=True, charset='utf8')


      cnx = MySQLdb.connect(db=path, user=user, passwd=password, host=host,
                              port=port, use_unicode=True)                

Attachments (0)

Change History (4)

comment:1 Changed 12 years ago by Brad Anderson

Resolution: invalid
Status: newclosed

This is a bug in Trac, or at least, different versioning of MySQLdb package. I encountered the same thing using 1.2.0 of MySQLdb and talked with dilinger on #trac at Freenode. He is using 1.2.1 and doesn't see the issue. I removed the charset param and it worked, but glad to see your mod works as well. You may want to post it on p.e.c.

In any case, this doesn't have much to do with the DbAuthPlugin

comment:2 Changed 12 years ago by Alec Thomas

Description: modified (diff)

comment:3 Changed 8 years ago by anonymous

Resolution: invalid
Status: closedreopened
Trac Release: 0.100.11

Had also had this problem using Trac with MySQL 5.0.26. After removing the charset variable on this function I got this error: UnicodeEncodeError: 'latin-1' codec can't encode character u'\u201c' in position 1153: ordinal not in range(256)

Any suggestions to it?

comment:4 Changed 8 years ago by Ryan J Ollos

Resolution: wontfix
Status: reopenedclosed

Closing tickets for a deprecated plugin.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Brad Anderson.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.