Ticket #1775 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

view source functionality should be more robust against buggy activities

Reported by: rgs Owned by: tomeu
Priority: Unspecified by Maintainer Milestone: 0.88
Component: sugar Version: Git as of bugdate
Severity: Major Keywords: r+, robust file existence check
Cc: walter Distribution/OS: Unspecified
Bug Status: New

Description

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.

Attachments

ta-view-source-support.py Download (1.1 KB) - added by rgs 3 years ago.
protect-view-source.patch Download (0.9 KB) - added by rgs 3 years ago.

Change History

Changed 3 years ago by rgs

Changed 3 years ago by rgs

Changed 3 years ago by erikos

  • keywords r?, added
  • status_field changed from Unconfirmed to New
  • severity changed from Unspecified to Major
  • milestone changed from Unspecified by Release Team to 0.88

Thanks for submitting the patch! I marked the ticket 'r?', as I guess you want to add it to the review queue. (  http://wiki.sugarlabs.org/go/Development_Team/Code_Review )

Changed 3 years ago by tomeu

  • keywords r+, added; r?, removed

Looks great to me, thanks!

Simon, can you add Raul to the Sugar committers?

Changed 3 years ago by erikos

I have added Raul to the Sugar committers. And pushed the patch:
 http://git.sugarlabs.org/projects/sugar/repos/mainline/commits/da1be6e637b636f16e476a00b07e64164609c1a9

Thanks Raul!

Changed 3 years ago by erikos

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.