Edgewall Software
Modify

Opened 8 years ago

Closed 4 years ago

#12547 closed defect (wontfix)

cursor.execute() requires list or tuple for 2nd argument in bugzilla2trac.py

Reported by: Jun Omae Owned by:
Priority: normal Milestone:
Component: contrib Version:
Severity: normal Keywords: bugzilla2trac
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I noticed this issue while reading r15012.

>>> import MySQLdb
>>> conn = MySQLdb.connect(user='root')
>>> cursor = conn.cursor()
>>> cursor.execute('SELECT %s', 'blah')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/venv/py25/lib/python2.5/site-packages/MySQLdb/cursors.py", line 187, in execute
    query = query % tuple([db.literal(item) for item in args])
TypeError: not all arguments converted during string formatting
>>> cursor.execute('SELECT %s', ['blah'])
1L
>>> list(cursor)
[('blah',)]

I think the following code should use a list and bugzilla2trac.py currently doesn't work….

     def getLoginName(self, cursor, userid):
         if userid not in self.loginNameCache:
-            cursor.execute("SELECT * FROM profiles WHERE userid = %s", (userid))
+            cursor.execute("SELECT * FROM profiles WHERE userid = %s",
+                           [userid])
             loginName = cursor.fetchall()

Untested patch: bugzilla2trac.diff.

Attachments (1)

bugzilla2trac.diff (3.5 KB ) - added by Jun Omae 8 years ago.

Download all attachments as: .zip

Change History (6)

by Jun Omae, 8 years ago

Attachment: bugzilla2trac.diff added

comment:1 by Ryan J Ollos, 8 years ago

Keywords: bugzilla2trac added

I think it would be a good idea to just go ahead and commit this since it looks like the script is completely broken. From the other open tickets it looks like there is a lot of work to do on bugzilla2trac and we could fix other problems later.

Also, we could use a tuple rather than list, (fieldid,), which seems to be the more common style used throughout the Trac codebase.

Last edited 8 years ago by Ryan J Ollos (previous) (diff)

comment:2 by Ryan J Ollos, 7 years ago

Milestone: next-stable-1.0.xnext-stable-1.2.x

Moved ticket assigned to next-stable-1.0.x since maintenance of 1.0.x is coming to a close. Please move the ticket back if it's critical to fix on 1.0.x.

comment:3 by Peter Suter, 6 years ago

([15027] referenced this ticket instead of #9612.)

comment:4 by Ryan J Ollos, 6 years ago

Minor fix to bugzilla2trac.py in r16664, merged in r16665, r16666.

comment:5 by Ryan J Ollos, 4 years ago

Milestone: next-stable-1.2.x
Resolution: wontfix
Status: newclosed

bugzilla2trac.py is no longer maintainer by Trac developers and is being deleted from the trunk. If you need the plugin, please consider copying it from 1.4-stable and creating a plugin on trac-hacks.org.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.