Opened 4 years ago
Closed 4 years ago
#22529 closed defect (fixed)
reset does not restore "quit"
Reported by:  zimmerma  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 4 years ago by
comment:2 Changed 4 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 4 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 4 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:5 Changed 4 years ago by
Oops, no, %reset
also kills Integer
and other sage imports.
comment:6 Changed 4 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 in reply to: ↑ 3 Changed 4 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:8 Changed 4 years ago by
Not correction above.
comment:9 Changed 4 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:10 Changed 4 years ago by
the patch proposed in comment 2 fixes the issue for me.
Paul
comment:11 Changed 4 years ago by
 Branch set to u/strogdon/reset_does_not_restore__quit_
comment:12 Changed 4 years ago by
 Commit set to 8725c635c3e1df92d76f7d31cd168f47c0b48a9b
 Status changed from new to 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 4 years ago by
 Commit changed from 8725c635c3e1df92d76f7d31cd168f47c0b48a9b to 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 4 years ago by
seems fine to me. However someone should check it works in the notebook too. Paul
comment:15 Changed 4 years ago by
 Reviewers set to Paul Zimmermann, John Palmieri
 Status changed from needs_review to 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 4 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 in reply to: ↑ 16 Changed 4 years ago by
comment:18 Changed 4 years ago by
 Milestone changed from sage7.6 to sage8.0
comment:19 Changed 4 years ago by
 Branch changed from u/strogdon/reset_does_not_restore__quit_ to cbd60fbb63b3c9283dd3f284c02950a51bd99086
 Resolution set to fixed
 Status changed from positive_review to closed
Neardup of #16704.