Opened 6 years ago

Closed 6 years ago

#17009 closed defect (fixed)

Unbound local in sageinspect

Reported by: SimonKing Owned by:
Priority: critical Milestone: sage-6.4
Component: misc Keywords:
Cc: vbraun, ncohen Merged in:
Authors: Simon King Reviewers: Volker Braun
Report Upstream: N/A Work issues:
Branch: 9d7f0e9 (Commits) Commit: 9d7f0e96feb5d66775fa847eff87e4736f5e6222
Dependencies: Stopgaps:


sage: from sage.misc.sageinspect import sage_getargspec
sage: sage_getargspec(gap)
Traceback (most recent call last):
UnboundLocalError: local variable 'func_obj' referenced before assignment

This has probably been introduced in #16309.

By consequence, one cannot see the documentation or source code of gap (even though one can edit the source code...). I'd say this is critical.

Change History (5)

comment:1 Changed 6 years ago by SimonKing

  • Authors set to Simon King
  • Status changed from new to needs_review

Fixed! There is some if ... else clause in sage_getargspec, simplified as follows:

if cond1:
        return answer1
    except AttributeError:
elif cond2:
    return answer2 or define func_obj
    return answer3 or define func_obj
do something with func_obj

So, the obvious problem is that upon catching the error, we want to do something with func_obj but haven't defined it. Solution: Replace elif by if. Test is added, needs review...

comment:2 Changed 6 years ago by SimonKing

  • Branch set to u/SimonKing/unbound_local_in_sageinspect
  • Commit set to 9d7f0e96feb5d66775fa847eff87e4736f5e6222

Why did git trac not succeed to set the branch field after pushing my branch? Strange.

Doing it manually now.

comment:3 Changed 6 years ago by vbraun

Did you post the first commit while the script was still uploading? There is a lock in trac to not have competing changes to a ticket...

comment:4 Changed 6 years ago by vbraun

  • Reviewers set to Volker Braun
  • Status changed from needs_review to positive_review

comment:5 Changed 6 years ago by vbraun

  • Branch changed from u/SimonKing/unbound_local_in_sageinspect to 9d7f0e96feb5d66775fa847eff87e4736f5e6222
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.