Modify

Opened 2 years ago

Closed 2 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 2 years ago by falkb

  • Owner changed from crossroad to falkb
  • Status changed from new to assigned

comment:2 Changed 2 years ago by falkb

  • Resolution set to fixed
  • Status changed from assigned to closed

(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

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from falkb. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.