Skip to content

Commit 45b651e

Browse files
committed
silence useless output with ipython 8.12
1 parent e9c3333 commit 45b651e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/sage/repl/inputhook.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import select
1919
import errno
20+
import contextlib
21+
import io
2022

2123
from IPython import get_ipython
2224
from IPython.terminal.pt_inputhooks import register
@@ -65,7 +67,9 @@ def install():
6567
if not ip:
6668
return # Not running in ipython, e.g. doctests
6769
if ip._inputhook != sage_inputhook:
68-
ip.enable_gui('sage')
70+
# silence `ip.enable_gui()` useless output
71+
with contextlib.redirect_stdout(io.StringIO()):
72+
ip.enable_gui('sage')
6973

7074

7175
def uninstall():
@@ -81,4 +85,6 @@ def uninstall():
8185
if not ip:
8286
return
8387
if ip._inputhook == sage_inputhook:
84-
ip.enable_gui(None)
88+
# silence `ip.enable_gui()` useless output
89+
with contextlib.redirect_stdout(io.StringIO()):
90+
ip.enable_gui(None)

0 commit comments

Comments
 (0)