Opened 4 years ago

Closed 3 years ago

#23125 closed defect (duplicate)

IPython 5.4 will need a minor change in Sage

Reported by: infinity0 Owned by:
Priority: minor Milestone: sage-8.0
Component: interfaces Keywords: ipython
Cc: Merged in:
Authors: Reviewers:
Report Upstream: None of the above - read trac for reasoning. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by infinity0)

Due to https://github.com/ipython/ipython/pull/10606 which was backported to IPython 5.4 and released yesterday, Sage's current doctests won't run against IPython 5.4. You'll need to apply this patch:

diff --git a/src/sage/interfaces/sage0.py b/src/sage/interfaces/sage0.py
index 56e6eba6c5..bcee80eaeb 100644
--- a/src/sage/interfaces/sage0.py
+++ b/src/sage/interfaces/sage0.py
@@ -160,7 +160,7 @@ class Sage(ExtraTabCompletion, Expect):
                 '--no-term-title',
                 '--simple-prompt',
             ])
-            prompt = re.compile('In \[\d+\]: ')
+            prompt = re.compile('sage: ') # needs to match SagePrompts
             if init_code is None:
                 init_code = ['from six.moves import cPickle']
 

It would be good to add some doctests, but I'm not sure what the best one would be. This works, but it feels a bit dirty to pass None to Prompt.__init__.

sage: from sage.repl.prompts import SagePrompts
sage: tokens = SagePrompts(None).in_prompt_tokens()
sage: prompt = "".join(x[1] for x in tokens)
sage: re.compile('sage: ').match(prompt)
<_sre.SRE_Match object at ...>

Change History (8)

comment:1 Changed 4 years ago by infinity0

  • Description modified (diff)

comment:2 Changed 4 years ago by infinity0

To clarify, a lot of doctests will run, but some will hang, including:

sage -t --long src/sage/misc/randstate.pyx  # Timed out
sage -t --long src/sage/interacts/debugger.py  # Timed out
sage -t --long src/sage/doctest/forker.py  # Timed out

and others.

comment:3 Changed 4 years ago by fbissey

Thanks for the warning.

comment:5 Changed 4 years ago by fbissey

I seem to have an extra doctest failure that I think is related to ipython 5.4

sage -t --long /usr/lib64/python2.7/site-packages/sage/doctest/forker.py
**********************************************************************
File "/usr/lib64/python2.7/site-packages/sage/doctest/forker.py", line 1123, in sage.doctest.forker.SageDocTestRunner.report_failure
Failed example:
    print(sage0.eval("sdf.init_sage(); DTR.run(DT, clear_globs=False)")) # indirect doctest
Expected:
    **********************************************************************
    Line 1, in doubling
    Failed example:
        2*a
    Expected:
        1
    Got:
        34
    **********************************************************************
    Previously executed commands:
    ...
Got:
    **********************************************************************
    Line 1, in doubling
    Failed example:
        2*a
    Expected:
        1
    Got:
        34
    **********************************************************************
    Previously executed commands:
**********************************************************************
File "/usr/lib64/python2.7/site-packages/sage/doctest/forker.py", line 1135, in sage.doctest.forker.SageDocTestRunner.report_failure
Failed example:
    sage0.eval("a")
Expected:
    '...17'
Got:
    ''
**********************************************************************
File "/usr/lib64/python2.7/site-packages/sage/doctest/forker.py", line 1137, in sage.doctest.forker.SageDocTestRunner.report_failure
Failed example:
    sage0.eval("quit")
Expected:
    'Returning to doctests...TestResults(failed=1, attempted=2)'
Got:
    '17'
**********************************************************************
1 item had failures:
   3 of  29 in sage.doctest.forker.SageDocTestRunner.report_failure
    [444 tests, 3 failures, 12.15 s]
----------------------------------------------------------------------
sage -t --long /usr/lib64/python2.7/site-packages/sage/doctest/forker.py  # 3 doctests failed
----------------------------------------------------------------------
Total time for all tests: 67.0 seconds
    cpu time: 2.7 seconds
    cumulative wall time: 12.1 seconds

comment:6 Changed 3 years ago by vbraun

Dupe of #24389

comment:7 Changed 3 years ago by vbraun

  • Status changed from new to needs_review

comment:8 Changed 3 years ago by jdemeyer

  • Resolution set to duplicate
  • Status changed from needs_review to closed
Note: See TracTickets for help on using tickets.