Modify

Opened 7 years ago

Closed 7 years ago

#2147 closed defect (fixed)

UnboundLocalError: local variable 'impl' referenced before assignment

Reported by: anonymous Owned by: athomas
Priority: normal Component: TracDeveloperPlugin
Severity: major Keywords:
Cc: Trac Release: 0.11

Description

(FYI, environment: Debian 4.0, sid; trac 0.11dev r6083)

I received the following error when I followed the "Plugins" link immediately after install:

Traceback (most recent call last):
  File "/var/lib/python-support/python2.5/trac/web/main.py", line 381, in dispatch_request
    dispatcher.dispatch(req)
  File "/var/lib/python-support/python2.5/trac/web/main.py", line 191, in dispatch
    resp = chosen_handler.process_request(req)
  File "/var/lib/python-support/python2.5/trac/admin/web_ui.py", line 108, in process_request
    path_info)
  File "/var/lib/python-support/python2.5/tracdeveloper/plugins.py", line 22, in render_admin_panel
    data = self.get_api(req)
  File "/var/lib/python-support/python2.5/tracdeveloper/plugins.py", line 71, in get_api
    interface_methods = [m['name'] for i in impl for m in i['methods']]
UnboundLocalError: local variable 'impl' referenced before assignment

I'm not sure if this is a fix or a workaround, as I just barely looked at the code. In any case, the below patch fixes the problem without causing any apparent problems (yet).

--- plugins.py.orig     2007-11-03 00:19:53.335412857 -0400
+++ plugins.py  2007-11-03 00:10:11.300490812 -0400
@@ -68,14 +68,15 @@
             if hasattr(component, '_implements'):
                 impl = [interfaces['%s.%s' % (i.__module__, i.__name__)]
                         for i in component._implements]
-            interface_methods = [m['name'] for i in impl for m in i['methods']]
+                interface_methods = [m['name'] for i in impl for m in i['methods']]
+                data['implements'] = impl
+                for imp in impl:
+                    imp['implemented_by'].append(data)
+
             methods = self.extract_methods(req, component, interface_methods)
             data = self.base_data(req, component)
             data['extensionpoints'] = self.extension_points(req, component)
-            data['implements'] = impl
             data['methods'] = methods
-            for imp in impl:
-                imp['implemented_by'].append(data)
             components[data['name']] = data
         api['components'] = components
         return api

Attachments (0)

Change History (1)

comment:1 Changed 7 years ago by athomas

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

Fixed in r2737, thanks.

Add Comment

Modify Ticket

Action
as closed The owner will remain athomas.
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.