Opened 6 years ago
Closed 5 years ago
#22529 closed defect (fixed)
reset does not restore "quit"
Reported by:  Paul Zimmermann  Owned by:  

Priority:  minor  Milestone:  sage8.0 
Component:  user interface  Keywords:  
Cc:  Merged in:  
Authors:  Steven Trogdon  Reviewers:  Paul Zimmermann, John Palmieri 
Report Upstream:  N/A  Work issues:  
Branch:  cbd60fb (Commits, GitHub, GitLab)  Commit:  cbd60fbb63b3c9283dd3f284c02950a51bd99086 
Dependencies:  Stopgaps: 
Description
with Sage 7.5.1:
sage: reset() sage: quit  NameError Traceback (most recent call last) /localdisk/tmp/sage7.5.1/local/lib/python2.7/sitepackages/sage/all_cmdline.pyc in <module>() > 1 quit NameError: name 'quit' is not defined
I believe reset() should restore exactly the initial state when starting Sage, including the quit
function.
Change History (19)
comment:1 Changed 6 years ago by
comment:2 Changed 6 years ago by
Will something as naive as
diff git a/src/sage/misc/reset.pyx b/src/sage/misc/reset.pyx index bd7c94b..21e1587 100644  a/src/sage/misc/reset.pyx +++ b/src/sage/misc/reset.pyx @@ 7,7 +7,7 @@ import sys # Exclude these from the reset command. # DATA, base64  needed by the notebook EXCLUDE = set(['sage_mode', '__DIR__', 'DIR', 'DATA', 'base64']) +EXCLUDE = set(['sage_mode', '__DIR__', 'DIR', 'DATA', 'base64', 'exit', 'quit']) def reset(vars=None, attached=False): """
do the job, or are there other ramifications that need to be addressed?
comment:3 followup: 7 Changed 6 years ago by
I was wondering about that solution, too. It seems to work in my very superficial testing. I also wonder if we should delete 'DIR', 'DATA', and 'base64' from EXCLUDE
.
comment:4 Changed 6 years ago by
Another idea: can we use the reset command from IPython? Type %reset
at the commandline to try it. It removes sage_mode
but preserves exit
and quit
.
comment:6 Changed 6 years ago by
Maybe use %reset s
, or %reset s f
to skip the confirmation. The command %reset_selective REGEXP
will reset any names matching REGEXP
:
sage: a = 3 sage: a2 = 5 sage: %whos Variable Type Data/Info  a Integer 3 a2 Integer 5 sage: %reset_selective a Once deleted, variables cannot be recovered. Proceed (y/[n])? y sage: %whos Interactive namespace is empty. sage: a = 3 sage: a2 = 5 sage: %reset_selective f ^a$ sage: %whos Variable Type Data/Info  a2 Integer 5
comment:7 Changed 6 years ago by
Replying to jhpalmieri:
I was wondering about that solution, too. It seems to work in my very superficial testing. I also wonder if we should delete 'DIR', 'DATA', and 'base64' from
EXCLUDE
.
I don't see that these are set anywhere, even from notebook imports. What about __DIR__
? I can't find it either.
comment:9 Changed 6 years ago by
When I search for these terms in the Sage tree, I see no hits (except for this one line in reset.pyx
) for __DIR__
, and nothing apparently relevant for DIR
, DATA
, or base64
. sage_mode
is used in src/sage/all_cmdline.py
and src/sage/all_notebook.py
.
comment:11 Changed 6 years ago by
Branch:  → u/strogdon/reset_does_not_restore__quit_ 

comment:12 Changed 6 years ago by
Authors:  → Steven Trogdon 

Commit:  → 8725c635c3e1df92d76f7d31cd168f47c0b48a9b 
Status:  new → needs_review 
I left __DIR__
, DIR
, DATA
and base64
in place as I found some reference to these variables in the sagenb
code. Feel free to alter.
comment:13 Changed 6 years ago by
Commit:  8725c635c3e1df92d76f7d31cd168f47c0b48a9b → cbd60fbb63b3c9283dd3f284c02950a51bd99086 

Branch pushed to git repo; I updated commit sha1. New commits:
cbd60fb  Add exit and quit to EXCLUDE for trac #22529 and trac #16704

comment:14 Changed 6 years ago by
seems fine to me. However someone should check it works in the notebook too. Paul
comment:15 Changed 5 years ago by
Reviewers:  → Paul Zimmermann, John Palmieri 

Status:  needs_review → positive_review 
Looks good to me. As far as I can tell, exit
and quit
don't do much in the old Sage notebook. They function as they should in the Jupyter notebook. Without this branch, reset()
kills them, and with this branch, it does not, and they continue to function.
comment:16 followup: 17 Changed 5 years ago by
So how do we deal with #16704? I don't see a dup
or some other appropriate button. Perhaps positive review there too?
comment:17 Changed 5 years ago by
comment:18 Changed 5 years ago by
Milestone:  sage7.6 → sage8.0 

comment:19 Changed 5 years ago by
Branch:  u/strogdon/reset_does_not_restore__quit_ → cbd60fbb63b3c9283dd3f284c02950a51bd99086 

Resolution:  → fixed 
Status:  positive_review → closed 
Neardup of #16704.