Menu

#3 driconf-0.9.1 uninitialized variable

open
None
5
2007-02-18
2007-02-10
No

An uninitialized variable in a driconf-0.9.1 file causes python to complain.

I start driconf from a terminal without a pre-existing ~/.drirc configuration file.

I open the "Application settings" dropdown at the bottom of the page.

I select "Add", and put in doom3-demo and doom.x86 in the dialog fields, and select "OK".

At this point driconf spews forth it's displeasure upon stderr:

Code:
Traceback (most recent call last):
File "/usr/lib/driconf/driconf_simpleui.py", line 692, in changeApp
self.selectApp(app)
File "/usr/lib/driconf/driconf_simpleui.py", line 641, in selectApp
self.appPage = AppPage (self.driver, app)
File "/usr/lib/driconf/driconf_simpleui.py", line 347, in __init__
self.refreshOptions()
File "/usr/lib/driconf/driconf_simpleui.py", line 369, in refreshOptions
self.optionTree.append(sectIter, [
File "/usr/lib/driconf/driconf_simpleui.py", line 271, in lineWrap
head, tail = head + tail[:i] + '\n', tail[j:]
UnboundLocalError: local variable 'j' referenced before assignment

It must be a python interpreter change. It seems like variables must be initialized before being used...

To fix it, add "j = i" at line 260 in /usr/lib/driconf/driconf_simpleui.py, after the existing line "i = chars"

Discussion

  • James C. Georgas

    Patch to fix the error described above

     
  • Felix Kuehling

    Felix Kuehling - 2007-02-18
    • assigned_to: nobody --> fxkuehl
     
  • Felix Kuehling

    Felix Kuehling - 2007-02-18

    Logged In: YES
    user_id=546104
    Originator: NO

    Thanks for catching this problem. Your solution would work, but I still found it difficult to wrap my head around the logic of this function, even though I wrote it. ;-) Can you try the patch below, making the whole thing a bit more robust? I'll apply that if it works for you.

    --- driconf_simpleui.py (Revision 284)
    +++ driconf_simpleui.py (Arbeitskopie)
    @@ -266,8 +266,8 @@
    j = i
    break
    i = i - 1
    - if i < chars/3:
    - i = chars
    + else:
    + i = j = chars
    head, tail = head + tail[:i] + '\n', tail[j:]
    return head

     

Log in to post a comment.