Skip to content

Commit 5ad2b3c

Browse files
committed
Fix FriCAS command execution for proper quitting
Updated command execution for FriCAS to use stdin for quitting instead of -eval to avoid misinterpretation by GCL-compiled FriCAS.
1 parent bd53c9c commit 5ad2b3c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/sage/features/fricas.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,16 @@ def is_functional(self):
6767
sage: FriCAS().is_functional() # optional - fricas
6868
FeatureTestResult('fricas', True)
6969
"""
70-
command = ['fricas -nosman -eval ")quit"']
70+
# Use stdin to pass the quit command instead of -eval because
71+
# GCL-compiled FriCAS misinterprets -eval ")quit" as a Lisp expression.
72+
# See :issue:`40569`.
73+
command = ['fricas', '-nosman']
7174
try:
72-
lines = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
75+
lines = subprocess.check_output(command, input=b')quit\n',
76+
stderr=subprocess.STDOUT, timeout=30)
77+
except subprocess.TimeoutExpired:
78+
return FeatureTestResult(self, False,
79+
reason="Call `{command}` timed out".format(command=" ".join(command)))
7380
except subprocess.CalledProcessError as e:
7481
return FeatureTestResult(self, False,
7582
reason="Call `{command}` failed with exit code {e.returncode}".format(command=" ".join(command), e=e))

0 commit comments

Comments
 (0)