Opened 14 years ago

Closed 14 years ago

#1042 closed defect (fixed)

[with patch] reset() doesn't restore anything in all_cmdline or all_notebook

Reported by: was Owned by: was
Priority: major Milestone: sage-2.8.12
Component: calculus Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

The reset command is supposed to reset all variables etc., back to their defaults. This is currently slightly broken, since the symbolic x doesn't get reset:

sage: reset()
sage: x
Traceback (most recent call last):
...
NameError: name 'x' is not defined
sage: factor(90823048)
2^3 * 11352881

I seem to recall implementing the symbolic being imported slightly differently, which is surely responsible for this bug.

Attachments (1)

trac1042.patch (1.1 KB) - added by was 14 years ago.
fixed by Mike Hansen and I.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 14 years ago by was

  • Milestone changed from sage-2.9.1 to sage-2.8.12

comment:2 Changed 14 years ago by mhansen

  • Summary changed from reset() doesn't do what's claimed -- in particular the symbolic x is gone after doing reset() but shouldn't be to reset() doesn't restore anything in all_cmdline or all_notebook

In reset.pyx,

    """
    G = globals()  # this is the reason the code must be in SageX.
    if not G.has_key('sage_mode'):
        import sage.all
        D = sage.all.__dict__
    else:
        mode = G['sage_mode']
        if mode == 'cmdline':
            import sage.all_cmdline
            D = sage.all_cmdline.__dict__            
        elif mode == 'notebook':
            import sage.all_notebook
            D = sage.all_notebook.__dict__            
        else:
            import sage.all
            D = sage.all.__dict__     

G never the key 'sage_mode' so none of the custom imports in all_cmdline and all_notebook will make it in after reset(). This is where 'x' is imported. Here is what 'print G' gives:

{'__nonzero__': <function __nonzero__ at 0x2b4a6a257b90>, '_iii': '', 
'__': '', '_i': '',
 '_i1': u'reset()\n',
 '__IP': <IPython.iplib.InteractiveShell object at 0x2b4a6aa0e790>,
 '_ii': '', '__builtins__': <module '__builtin__' (built-in)>,
 '___': '', 
'_ih': ['\n', u'reset()\n'], 
'__file__': '/opt/sage/local/lib/python2.5/site-packages/IPython/FakeModule.pyc', 
'_dh': ['/opt/sage/local/bin'], '__name__': '__main__', '_': None, '_oh': {}}

Changed 14 years ago by was

fixed by Mike Hansen and I.

comment:3 Changed 14 years ago by was

  • Resolution set to fixed
  • Status changed from new to closed
  • Summary changed from reset() doesn't restore anything in all_cmdline or all_notebook to [with patch] reset() doesn't restore anything in all_cmdline or all_notebook
Note: See TracTickets for help on using tickets.