-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
can't exit or detach after error in attached file #14523
Comments
comment:1
|
Author: Volker Braun |
comment:3
I'm not knowledgeable enough to offer a useful review of the code. It does seem like a good solution to the observed problem. There is a behaviour of "attach" which bugs me. If the file you try to attach generates an error when you attach it, then it doesn't actually get attached. I don't see the point of this. It makes even less sense now than before. Would it be easy to fix on this ticket, or should I open another one? I do also have one comment about the current patch -- if it wouldn't be too complicated, I think it would be nice to get a new sage prompt after the reloading is finished, to indicate that it has completed. |
comment:4
Updated patch
|
comment:6
Thanks very much! (I have tested attaching a file with an error.) |
comment:7
Bonus: this also seems to fix the issue reported at #14149: when files are attached, spurious files are created in the current directory. |
comment:8
Updated patch fixes some minor things, makes imports lazy, and adds doctests. |
comment:9
|
comment:10
I think the "debug mode" for load and attach should be removed. Files should always be preparsed in memory. We should keep a user-accessible list of loaded/attached files with some state, preparsed form, etc. Any debugging that you can do with temporary files can be done much nicer by querying the files on the command line. But thats for another ticket. |
comment:11
Replying to @vbraun:
I don't understand the last sentence, and (so?) I completely disagree with the rest. Tracebacks for attached files should be completely detailed, with code snippets. Anything that has to be done by hand for each of the steps in the traceback is far from as useful as immediately seeing the code itself. See #11812 and this discussion. |
comment:12
The updated patch
|
comment:13
Is |
comment:14
Replying to @nexttime:
Just checked in vanilla Sage 5.10.beta1, and there indeed three doctests fail (in So apparently this is not new, but could you also fix it here? |
comment:15
I think the undocumented |
comment:16
Replying to @vbraun:
I have no strong opinion on doing so. Although it's apparently not documented (at least not in Sage's documentation besides the docstring; it may get mentioned in some 3rd party documentation), I bet a couple of people will complain (probably much) later if we remove it... ;-) But I'd rather tend to leave the (IMHO convenient) functionality, probably documenting it more prominently (it doesn't really fit into the Sage Installation Guide, just like other environment variables, which is a different story), and fixing potential doctest failures (which is a minor issue anyway) -- elsewhere, on another ticket.
So you don't intend to remove it here either? (Ok for me, just asking.) |
comment:17
Replying to @nexttime:
No, I'd rather leave that for later. The whole load/attach functionality should be collected into an object instead of multiple global functions, including the search path functionality. Then we can go ahead and deprecate |
comment:18
Fixed failing doctest on patchbot |
Dependencies: #14266 |
comment:19
Conflicts with the otherwise unrelated #14266, this is now a dependency. |
Updated patch |
comment:20
Attachment: trac_14523_improve_attach.patch.gz Hey Volker, Looks good for the most part. It's somewhat minor, but is there some way we can get it so that we get it to end with the sage prompt? For me it currently ends at a blank line, although it still accepts input correctly. Thanks, Travis |
comment:21
Its not just print a new prompt, you want to redraw the current line (since you could have a partially-written command there). I think its possible to call |
Reviewer: Travis Scrimshaw |
comment:22
True. I'm happy with getting this into Sage as is. |
comment:25
Another issue: computations from attach'ed files are uninterruptable. This is because readline installs its own signal handlers while it is sitting at the input prompt, and (by default) only restores the previous handler when you press enter. |
comment:27
A closer reading of IPython reveals that it intentionally overwrites the SIGINT handler when you set an inputhook (as we do to poll for file changes). So interrupting computations is completely messed up, even if its not attached. I'm working on a new patch... |
This comment has been minimized.
This comment has been minimized.
comment:28
All subsequent changes will be in the separate |
comment:29
I also added an interface to readline so we can redraw the prompt. |
comment:30
Also fixed Jeroen's doctest failures. First is stale python file (you need to run |
comment:31
Slightly beautified so the old command line is erased:
Now edit and save attached file, and you get
On a related note, attaching files in the notebook is completely broken (with and without this ticket). |
comment:32
Notebook issue is here: sagemath/sagenb#169 |
comment:33
Patch rebased for sage-5.11.beta1 (not yet released) |
comment:34
I'm getting doctest failures:
|
Attachment: trac_14523_readline.2.patch.gz Updated patch |
Attachment: trac_14523_readline.patch.gz Updated patch |
comment:35
Thanks, fixed. Was another instance of filesytem timestamp granularity in the doctest. patchbot: |
comment:38
Hey Volker, Sorry for letting this sit for so long. Looks good to me (I remembered to run sync-build this time to remove the old files before testing). (Side note, does the patchbot run sync-build after applying patches? If not, I think doing this would be beneficial.) Best, Travis |
comment:39
Thanks! I believe the patchbot uses separate branches so it doesn't have to sync-build. |
Merged: sage-5.11.rc0 |
comment:41
See http://ask.sagemath.org/question/3084/notebook-and-initsage and #15308. |
comment:42
See #16784 for a followup. |
It seems like the only way to continue using this Sage session is to fix the error first. But suppose you have some reason not to (e.g. are in a hurry, and the error is hard to fix). I think it would be much better if Sage was to evaluate "1+1" and especially "exit" and "detach" even when unable to reload one of the attached files.
Possible ways to fix this are discussed on sage-devel.
Apply
Depends on #14266
CC: @nexttime @nbruin @seblabbe
Component: user interface
Author: Volker Braun
Reviewer: Travis Scrimshaw
Merged: sage-5.11.rc0
Issue created by migration from https://trac.sagemath.org/ticket/14523
The text was updated successfully, but these errors were encountered: