Modify ↓
Opened 11 years ago
Closed 11 years ago
#11313 closed defect (fixed)
mysql_backend with parameters raises TypeError on initenv
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.2 |
Component: | database backend | Version: | 1.0-stable |
Severity: | normal | Keywords: | mysql |
Cc: | Branch: | ||
Release Notes: |
Fix errors if |
||
API Changes: | |||
Internal Changes: |
Description
When executing initenv
command with mysql backend and init_command
parameter, it raises TypeError: Connect() keywords must be strings
.
Parameters for mysql backend are introduced in [10407], #5120.
$ python trac/admin/console.py /var/trac/1.0-test Welcome to trac-admin 1.0.2dev Interactive Trac administration console. Copyright (C) 2003-2013 Edgewall Software Type: '?' or 'help' for help on commands. Trac [/var/trac/1.0-test]> initenv "Trac 1.0-stable w/ MySQL" "mysql://tracuser:password@localhost/trac_1_0_test?init_command=SET storage_engine%3dMyISAM" Creating and Initializing Project Initenv for '/var/trac/1.0-test' failed. Failed to create environment. Connect() keywords must be strings Traceback (most recent call last): File "trac/admin/console.py", line 456, in do_initenv options=options) File "/home/jun66j5/src/trac/edgewall/git/trac/core.py", line 124, in __call__ self.__init__(*args, **kwargs) File "/home/jun66j5/src/trac/edgewall/git/trac/env.py", line 280, in __init__ self.create(options) File "/home/jun66j5/src/trac/edgewall/git/trac/env.py", line 580, in create DatabaseManager(self).init_db() File "/home/jun66j5/src/trac/edgewall/git/trac/db/api.py", line 251, in init_db connector.init_db(**args) File "/home/jun66j5/src/trac/edgewall/git/trac/db/mysql_backend.py", line 111, in init_db params) File "/home/jun66j5/src/trac/edgewall/git/trac/db/mysql_backend.py", line 92, in get_connection cnx = MySQLConnection(path, log, user, password, host, port, params) File "/home/jun66j5/src/trac/edgewall/git/trac/db/mysql_backend.py", line 275, in __init__ port=port, charset='utf8', **opts) TypeError: Connect() keywords must be strings make: *** [console] Error 1
-
trac/db/mysql_backend.py
diff --git a/trac/db/mysql_backend.py b/trac/db/mysql_backend.py index cea17b2..b2537c6 100644
a b class MySQLConnection(ConnectionWrapper): 263 263 port = 3306 264 264 opts = {} 265 265 for name, value in params.iteritems(): 266 name = name.encode('utf-8') 266 267 if name in ('init_command', 'read_default_file', 267 268 'read_default_group', 'unix_socket'): 268 269 opts[name] = value
Attachments (0)
Change History (2)
comment:1 by , 11 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:2 by , 11 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
And another thing, raising UnicodeEncodeError
if init_command
with unicode.
Trac [/var/trac/1.0-test]> initenv "my project" "mysql://tracuser:password@localhost/trac_1_0_test?init_command=SET storage_engine=InnoDB -- é (U+009E)" ... File "/usr/lib/python2.5/site-packages/MySQLdb/connections.py", line 187, in __init__ super(Connection, self).__init__(*args, **kwargs2) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 29: ordinal not in range(128)
The proposed fix can be found in [139420d06/jomae.git].
Those changes have been pushed in [12113] and merged into trunk in [12114].
Note:
See TracTickets
for help on using tickets.
Also, I've found another thing. We should convert the file paths in
unix_socket
andread_default_file
to filesystem encoding. If passing a path as unicode, those are converted with default encoding.Proposed changes can be found in [103926c7/jomae.git].