b34d0bbd28
Also fix doctests for pkg updates: - matplotlib 3.7 - ipython 8.12 - nauty 2.8.6 - pythran 0.12.1 And add support for: - networkx 3.1 We use patches from upstream sagemath to fix all of these. We also add pythran and sphinx to checkdepends to make sure doctests pass when they are installed.
51 lines
1.5 KiB
Diff
51 lines
1.5 KiB
Diff
diff --git a/src/sage/repl/inputhook.py b/src/sage/repl/inputhook.py
|
|
index da5df0268c0..7f7894f6dcf 100644
|
|
--- a/src/sage/repl/inputhook.py
|
|
+++ b/src/sage/repl/inputhook.py
|
|
@@ -17,6 +17,8 @@
|
|
|
|
import select
|
|
import errno
|
|
+import contextlib
|
|
+import io
|
|
|
|
from IPython import get_ipython
|
|
from IPython.terminal.pt_inputhooks import register
|
|
@@ -47,15 +49,27 @@ def install():
|
|
"""
|
|
Install the Sage input hook
|
|
|
|
- EXAMPLES::
|
|
+ EXAMPLES:
|
|
+
|
|
+ Make sure ipython is running so we really test this function::
|
|
+
|
|
+ sage: from sage.repl.interpreter import get_test_shell
|
|
+ sage: get_test_shell()
|
|
+ <sage.repl.interpreter.SageTestShell object at ...>
|
|
+
|
|
+ Run the function twice, to check it is idempotent (see :trac:`35235`)::
|
|
|
|
sage: from sage.repl.inputhook import install
|
|
sage: install()
|
|
+ sage: install()
|
|
"""
|
|
ip = get_ipython()
|
|
if not ip:
|
|
return # Not running in ipython, e.g. doctests
|
|
- ip.enable_gui('sage')
|
|
+ if ip._inputhook != sage_inputhook:
|
|
+ # silence `ip.enable_gui()` useless output
|
|
+ with contextlib.redirect_stdout(io.StringIO()):
|
|
+ ip.enable_gui('sage')
|
|
|
|
|
|
def uninstall():
|
|
@@ -71,4 +85,6 @@ def uninstall():
|
|
if not ip:
|
|
return
|
|
if ip._inputhook == sage_inputhook:
|
|
- ip.enable_gui(None)
|
|
+ # silence `ip.enable_gui()` useless output
|
|
+ with contextlib.redirect_stdout(io.StringIO()):
|
|
+ ip.enable_gui(None)
|