[Bugs] #1775 UNSP: view source functionality should be more robust against buggy activities
Sugar Labs Bugs
bugtracker-noreply at sugarlabs.org
Tue Mar 2 22:31:58 EST 2010
#1775: view source functionality should be more robust against buggy activities
------------------------------------------+---------------------------------
Reporter: rgs | Owner: tomeu
Type: defect | Status: new
Priority: Unspecified by Maintainer | Milestone: Unspecified by Release Team
Component: sugar | Version: Git as of bugdate
Severity: Unspecified | Keywords: robust file existence check
Distribution: Unspecified | Status_field: Unconfirmed
------------------------------------------+---------------------------------
Scenario:
We added view-source support to TurtleArt (see attached code snippet). I
manage to hit a code path (a race condition somewhere or problem accessing
the temp file) in which I got the following exception (in
~/.sugar/default/logs/shell.log):
{{{
File "/usr/lib/python2.6/dist-packages/jarabe/view/viewsource.py", line
291, in __init__
activity_button.props.group = document_button
UnboundLocalError: local variable 'document_button' referenced before
assignment
}}}
Checking the constructor of the Toolbar class in jarabe/view/viewsource.py
it seems like the following test:
{{{
if document_path is not None:
}}}
forgets to check file existence as the previous conditional does:
{{{
if document_path is not None and os.path.exists(document_path)
}}}
The attached patch proposes a fix by starting document_button to None
which seems cheaper then testing for the existence of a file twice.
--
Ticket URL: <http://bugs.sugarlabs.org/ticket/1775>
Sugar Labs <http://sugarlabs.org/>
Sugar Labs bug tracking system
More information about the Bugs
mailing list