@@ -22,21 +22,26 @@ def inspect_eval_loop(evaluation: Evaluation):
22
22
A read eval/loop for an Interrupt's "inspect" command.
23
23
"""
24
24
shell = evaluation .shell
25
- was_inside_interrupt = shell .is_inside_interrupt
26
- shell .is_inside_interrupt = True
25
+ if shell is not None :
26
+ was_inside_interrupt = shell .is_inside_interrupt
27
+ shell .is_inside_interrupt = True
28
+ else :
29
+ was_inside_interrupt = False
30
+
27
31
previous_recursion_depth = evaluation .recursion_depth
28
32
while True :
29
33
try :
30
34
query , source_code = evaluation .parse_feeder_returning_code (shell )
31
35
# show_echo(source_code, evaluation)
32
- if len (source_code ) and source_code [0 ] == "!" :
36
+ if len (source_code ) and source_code [0 ] == "!" and shell is not None :
33
37
subprocess .run (source_code [1 :], shell = True )
34
- shell .definitions .increment_line_no (1 )
38
+ if shell .definitions is not None :
39
+ shell .definitions .increment_line_no (1 )
35
40
continue
36
41
if query is None :
37
42
continue
38
43
result = evaluation .evaluate (query , timeout = settings .TIMEOUT )
39
- if result is not None :
44
+ if result is not None and shell is not None :
40
45
shell .print_result (result , strict_wl_output = True )
41
46
except TimeoutInterrupt :
42
47
print ("\n Timeout occurred - ignored." )
@@ -56,7 +61,8 @@ def inspect_eval_loop(evaluation: Evaluation):
56
61
raise
57
62
finally :
58
63
evaluation .recursion_depth = previous_recursion_depth
59
- shell .is_inside_interrupt = was_inside_interrupt
64
+ if shell is not None :
65
+ shell .is_inside_interrupt = was_inside_interrupt
60
66
61
67
62
68
def mathics3_interrupt_handler (evaluation : Optional [Evaluation ]):
@@ -81,12 +87,14 @@ def mathics3_interrupt_handler(evaluation: Optional[Evaluation]):
81
87
print ("inspecting" )
82
88
if evaluation is not None :
83
89
evaluation .message ("Interrupt" , "dgbgn" )
84
- inspect_eval_loop (evaluation )
90
+ inspect_eval_loop (evaluation )
85
91
86
92
elif user_input in ("show" , "s" ):
87
93
# In some cases we can better, by going back to the caller
88
94
# and reconstructing the actual call with arguments.
89
95
eval_frame = find_mathics3_evaluation_method (inspect .currentframe ())
96
+ if eval_frame is None :
97
+ continue
90
98
eval_method_name = eval_frame .f_code .co_name
91
99
eval_method = getattr (eval_frame .f_locals .get ("self" ), eval_method_name )
92
100
if eval_method :
0 commit comments