Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset does not restore "quit" #22529

Closed
zimmermann6 opened this issue Mar 6, 2017 · 22 comments
Closed

reset does not restore "quit" #22529

zimmermann6 opened this issue Mar 6, 2017 · 22 comments

Comments

@zimmermann6
Copy link

with Sage 7.5.1:

sage: reset()
sage: quit
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/localdisk/tmp/sage-7.5.1/local/lib/python2.7/site-packages/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.

Component: user interface

Author: Steven Trogdon

Branch/Commit: cbd60fb

Reviewer: Paul Zimmermann, John Palmieri

Issue created by migration from https://trac.sagemath.org/ticket/22529

@mkoeppe
Copy link
Member

mkoeppe commented Mar 6, 2017

comment:1

Near-dup of #16704.

@strogdon
Copy link

comment:2

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?

@jhpalmieri
Copy link
Member

comment:3

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.

@jhpalmieri
Copy link
Member

comment:4

Another idea: can we use the reset command from IPython? Type %reset at the command-line to try it. It removes sage_mode but preserves exit and quit.

@jhpalmieri
Copy link
Member

comment:5

Oops, no, %reset also kills Integer and other sage imports.

@jhpalmieri
Copy link
Member

comment:6

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

@strogdon
Copy link

comment:7

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.

@strogdon
Copy link

comment:8

Not correction above.

@jhpalmieri
Copy link
Member

comment:9

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.

@zimmermann6
Copy link
Author

comment:10

the patch proposed in comment [comment:2] fixes the issue for me.

Paul

@strogdon
Copy link

strogdon commented Apr 4, 2017

@strogdon
Copy link

strogdon commented Apr 4, 2017

Author: Steven Trogdon

@strogdon
Copy link

strogdon commented Apr 4, 2017

comment:12

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.

@strogdon
Copy link

strogdon commented Apr 4, 2017

Commit: 8725c63

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 4, 2017

Changed commit from 8725c63 to cbd60fb

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 4, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

cbd60fbAdd exit and quit to EXCLUDE for trac #22529 and trac #16704

@zimmermann6
Copy link
Author

comment:14

seems fine to me. However someone should check it works in the notebook too.
Paul

@jhpalmieri
Copy link
Member

Reviewer: Paul Zimmermann, John Palmieri

@jhpalmieri
Copy link
Member

comment:15

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.

@strogdon
Copy link

comment:16

So how do we deal with #16704? I don't see a dup or some other appropriate button. Perhaps positive review there too?

@zimmermann6
Copy link
Author

comment:17

Replying to @strogdon:

So how do we deal with #16704? I don't see a dup or some other appropriate button. Perhaps positive review there too?

you should modify that other ticket as "resolved as duplicate".

Paul

@jhpalmieri jhpalmieri modified the milestones: sage-7.6, sage-8.0 Apr 13, 2017
@vbraun
Copy link
Member

vbraun commented Apr 14, 2017

Changed branch from u/strogdon/reset_does_not_restore__quit_ to cbd60fb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants