Skip to content

Commit 50767c4

Browse files
author
Release Manager
committed
gh-35423: Fix doctests with ipython 8.12 ### 📚 Description As reported in #35337 (comment), the update to ipython 8.12 introduces some useless output when calling `get_ipython().enable_gui(...)` which causes a few doctest failures. This PR silences this output by (temporarily) redirecting stdout to a string. This is only one commit that sits right on top of https://github.com/sag emath/sage/commit/e9c3333d4145bf631f0eae91514219479e1000ef from #35337. ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] Existing tests already cover the changes. ### ⌛ Dependencies - #35337 URL: #35423 Reported by: Gonzalo Tornaría Reviewer(s): François Bissey
2 parents 17d2e17 + 45b651e commit 50767c4

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)