Repository navigation
Leaving the inspect dialog resumes the interrupted evaluation - #2123
Closed
tombouctou wants to merge 1 commit into
Closed
tombouctou wants to merge 1 commit into
tombouctou wants to merge 1 commit into
Conversation
Ctrl-C during an evaluation, "inspect", some input, then Ctrl-D: the interrupted evaluation stopped with "Timeout reached" and $Aborted rather than going on. The dialog evaluates its input with the same Evaluation object, and Evaluation.evaluate() resets its state and ends with stop(), so the resumed evaluation found stopped = True at its next check. The dialog now saves the interrupted evaluation's state (stopped, timeout, deadline, counters, the pending messages, ...) and puts it back after each input, as it already did for recursion_depth. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mmatera
reviewed
Nov 7, 2026
| from mathics.eval.stackframe import find_Mathics3_evaluation_method, get_eval_Expression | ||
|
|
||
|
|
||
| # The state of an evaluation that Evaluation.evaluate() resets and leaves |
Contributor
There was a problem hiding this comment.
Maybe this should be an Enumeration
Member
There was a problem hiding this comment.
The sense I am getting is that AI is good with several things, but it can use or tolerate older forms of Python, and also does not pick up that well on the existing style and practice of existing code (unless explicitly directed to). I suspect this is also why we see so many isort/black failures initially as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while testing Ctrl-C for #2121 by driving the CLI through a pseudo-terminal.
Before: Ctrl-C during
Pause[8]; 7, theni, then1+1, then Ctrl-D:The dialog evaluates its input with the interrupted
Evaluationobject.Evaluation.evaluate()resets that object's state and ends withstop(), so once the dialog closes, the resumed evaluation findsstopped = Trueat its nextcheck_stopped().Now: the dialog saves the interrupted evaluation's state (
stopped,timeout,deadline, counters, pending messages, ...) and puts it back after each input, as it already did forrecursion_depth:Test:
test/test_interrupt_inspect.pyrunsinspect_eval_loopwith a shell that types1+1and then Ctrl-D. The interrupted evaluation must come back not stopped, with its recursion depth and pending messages. It fails without the fix. I also checked the whole sequence end to end in a pseudo-terminal.Not changed here: line numbers around a dialog. The dialog's
1+1is labelledOut[1]. The resumed result is printed asOut[2]= 7but stored asOut[1], andOut[2]is left unset ({Out[1], Out[2], $Line}gives{7, %2, 3}). Which numbers should a dialog and the resumed evaluation get? I didn't want to guess at WMA's behavior.🤖 Generated with Claude Code