sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.45k stars 482 forks source link

fix problem with leading space in FriCAS interface #25606

Closed mantepse closed 6 years ago

mantepse commented 6 years ago

Currently, long lines my get parsed wrong, as the leading double quote in the following example shows. This ticket makes the parsing (slightly) more robust.

sage: fricas.get_string("unparse((-1234567890123456789012345678901234567890123456789012345678901234567890*n::EXPR INT)::INFORM)")
'"(-1234567890123456789012345678901234567890123456789012345678901234567890)*n'

CC: @rwst

Component: interfaces: optional

Keywords: FriCAS

Author: Martin Rubey

Branch/Commit: 47f631c

Reviewer: Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/25606

mantepse commented 6 years ago

Branch: u/mantepse/fix_problem_with_leading_space_in_fricas_interface

mantepse commented 6 years ago

Description changed:

--- 
+++ 
@@ -1 +1,6 @@
+Currently, long lines my get parsed wrong, as the leading double quote in the following example shows.  This ticket makes the parsing (slightly) more robust.

+```
+sage: fricas.get_string("unparse((-1234567890123456789012345678901234567890123456789012345678901234567890*n::EXPR INT)::INFORM)")
+'"(-1234567890123456789012345678901234567890123456789012345678901234567890)*n'
+```
mantepse commented 6 years ago

Commit: 8a6bc91

mantepse commented 6 years ago

Author: Martin Rubey

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Changed commit from 8a6bc91 to ef80dba

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

ef80dbamake parsing of output a little more robust
mantepse commented 6 years ago

Changed keywords from none to FriCAS

fchapoton commented 6 years ago
comment:5

ok

fchapoton commented 6 years ago

Reviewer: Frédéric Chapoton

vbraun commented 6 years ago
comment:6
sage -t --long src/sage/interfaces/fricas.py
**********************************************************************
File "src/sage/interfaces/fricas.py", line 602, in sage.interfaces.fricas.FriCAS.get_string
Failed example:
    fricas.get_string("unparse((-1234567890123456789012345678901234567890123456789012345678901234567890*n::EXPR INT)::INFORM)")
Exception raised:
    Traceback (most recent call last):
      File "/mnt/disk/home/release/Sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 573, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/mnt/disk/home/release/Sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 983, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.interfaces.fricas.FriCAS.get_string[0]>", line 1, in <module>
        fricas.get_string("unparse((-1234567890123456789012345678901234567890123456789012345678901234567890*n::EXPR INT)::INFORM)")
      File "/mnt/disk/home/release/Sage/local/lib/python2.7/site-packages/sage/interfaces/fricas.py", line 608, in get_string
        return self.get(str(var)).replace("\n", "").strip()[1:-1]
      File "/mnt/disk/home/release/Sage/local/lib/python2.7/site-packages/sage/interfaces/fricas.py", line 569, in get
        output = self.eval(str(var), reformat=False)
      File "/mnt/disk/home/release/Sage/local/lib/python2.7/site-packages/sage/interfaces/fricas.py", line 774, in eval
        **kwds)
      File "/mnt/disk/home/release/Sage/local/lib/python2.7/site-packages/sage/interfaces/expect.py", line 1354, in eval
        for L in code.split('\n') if L != ''])
      File "/mnt/disk/home/release/Sage/local/lib/python2.7/site-packages/sage/interfaces/expect.py", line 917, in _eval_line
        self._start()
      File "/mnt/disk/home/release/Sage/local/lib/python2.7/site-packages/sage/interfaces/fricas.py", line 296, in _start
        Expect._start(self)
      File "/mnt/disk/home/release/Sage/local/lib/python2.7/site-packages/sage/interfaces/expect.py", line 508, in _start
        (self.name(), cmd, e, self._install_hints()))
    RuntimeError: unable to start fricas because the command 'fricas -nosman' failed: The command was not found or was not executable: fricas.

**********************************************************************
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

47f631cadd missing # optional - fricas
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Changed commit from ef80dba to 47f631c

mantepse commented 6 years ago
comment:8

Thank you for catching that!

mantepse commented 6 years ago
comment:9

(the pyflakes stuff is fixed in #25544)

fchapoton commented 6 years ago
comment:10

ok. Sorry for that.

vbraun commented 6 years ago

Changed branch from u/mantepse/fix_problem_with_leading_space_in_fricas_interface to 47f631c