Ticket #5929: trac_5929-fix_assumption_hang.patch

File trac_5929-fix_assumption_hang.patch, 1.4 KB (added by tornaria, 10 years ago)

fix for assumption hang with ecl

  • sage/interfaces/maxima.py

    # HG changeset patch
    # User Gonzalo Tornaría <tornaria@math.utexas.edu>
    # Date 1242012575 10800
    # Node ID 6d2592134149124dbc731217340e8a8af7384539
    # Parent  891da50821bd920d08245dfb718a0f99bda908cc
    For #5929: fix hang in maxima/ecl due to assumption questions
    
    When maxima asks a question, current code sends CTRL-C
    twice to break, then raises an exception. This used to work with
    clisp, but for ecl it actually hangs. A test case is given by
    
    {{{
    var("Ax,Bx,By")
    t = -Ax*sin(sqrt(Ax^2)/2)/(sqrt(Ax^2)*sqrt(By^2 + Bx^2))
    limit(t, Ax=0)
    }}}
    
    It turns out that it is possible to "break" from the question by just
    sending ";" by itself to maxima. The current patch changes to this
    method of escaping. It works with clisp or ecl.
    
    diff -r 891da50821bd -r 6d2592134149 sage/interfaces/maxima.py
    a b  
    627627                v = v[j:]
    628628                k = v.find(' ',4)
    629629                msg = "Computation failed since Maxima requested additional constraints (try the command 'assume(" + v[4:k] +">0)' before integral or limit evaluation, for example):\n" + v + self._ask[i-1]
    630                 self._sendstr(chr(3))
    631                 self._sendstr(chr(3))
     630                self._sendline(";")
    632631                self._expect_expr()
    633632                raise ValueError, msg
    634633        except KeyboardInterrupt, msg: