Modify

Opened 12 years ago

Closed 12 years ago

#10124 closed defect (fixed)

UnboundLocalError: local variable 'data' referenced before assignment

Reported by: loic@… Owned by: falkb
Priority: lowest Component: SimpleMultiProjectPlugin
Severity: trivial Keywords:
Cc: Trac Release: 0.12

Description

Hi, I had this little issue with SimpleMultiProjectPlugin today, when after I added a new project, I had the following error in the logs :

2012-06-26 17:51:29,193 Trac[admin] ERROR: Add Project Error: not all arguments converted during string formatting
2012-06-26 17:51:29,194 Trac[admin] ERROR: SimpleMultiProject Error: Failed to added project 'test 1'
2012-06-26 17:51:29,197 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
  File "build/bdist.freebsd-8.2-RELEASE-amd64/egg/trac/web/main.py", line 511, in _dispatch_request
    dispatcher.dispatch(req)
  File "build/bdist.freebsd-8.2-RELEASE-amd64/egg/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.freebsd-8.2-RELEASE-amd64/egg/trac/admin/web_ui.py", line 116, in process_request
    path_info)
  File "build/bdist.freebsd-8.2-RELEASE-amd64/egg/simplemultiproject/admin.py", line 118, in render_admin_panel
    return 'simplemultiproject_adminpanel.html', data
UnboundLocalError: local variable 'data' referenced before assignment

So I tracked down the problem, and found that the insert_project method in model.py seemed to be wrong :

    def insert_project(self, name, summary, description):
	        cursor = self.__get_cursor()
	        query    = """INSERT INTO
	                        smp_project (name, summary, description)
	                      VALUES ('%s', '%s');""" % (name, summary, description)
	
		cursor.execute(query)
	        self.__start_transacction()

At line 111 VALUES ('%s', '%s');""" % (name, summary, description), it should be 111 VALUES ('%s', '%s', '%s');""" % (name, summary, description) if I'm not mistaken. I made the change, and I can now add a new project.

Attachments (0)

Change History (2)

comment:1 Changed 12 years ago by falkb

Owner: changed from Christopher Paredes to falkb
Status: newassigned

comment:2 Changed 12 years ago by falkb

Resolution: fixed
Status: assignedclosed

(In [11695]) fixed #10124 (Thanks to loic for the bugfix patch!): insert_project() missed a %s, the effect was "UnboundLocalError: local variable 'data' referenced before assignment" in simplemultiproject_adminpanel.html

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain falkb.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.