1010from types import FrameType
1111from typing import Callable , Optional
1212
13- from numpy import true_divide
14-
1513from mathics import settings
1614from mathics .core .evaluation import Evaluation
1715from mathics .core .interrupt import AbortInterrupt , ReturnInterrupt , TimeoutInterrupt
@@ -53,6 +51,7 @@ def inspect_eval_loop(evaluation: Evaluation):
5351 if result is not None and shell is not None :
5452 shell .print_result (result , prompt = False , strict_wl_output = True )
5553 except TimeoutInterrupt :
54+ print ("\n Timeout occurred - ignored." )
5655 pass
5756 except ReturnInterrupt :
5857 evaluation .last_eval = None
@@ -79,6 +78,7 @@ def Mathics3_interrupt_handler(
7978
8079 shell = evaluation .shell
8180 incolors = shell .incolors
81+ is_gnu_readline = False
8282 if hasattr (shell , "bottom_toolbar" ):
8383 from mathicsscript .completion import InterruptCompleter
8484
@@ -87,8 +87,13 @@ def Mathics3_interrupt_handler(
8787 completer = InterruptCompleter ()
8888 else :
8989 is_prompt_toolkit = False
90+ is_gnu_readline = shell .using_readline
9091 use_HTML = False
92+ from readline import set_completer
93+
94+ set_completer (lambda text , state : shell .complete_interrupt_command (text , state ))
9195 completer = None
96+
9297 while True :
9398 try :
9499 prompt = (
@@ -162,6 +167,12 @@ def Mathics3_interrupt_handler(
162167 except RuntimeError :
163168 break
164169 finally :
170+ if is_gnu_readline :
171+ from readline import set_completer
172+
173+ set_completer (
174+ lambda text , state : shell .complete_symbol_name (text , state )
175+ )
165176 pass
166177
167178
0 commit comments