10000 Merge pull request #25496 from dnicolodi/fix-ipython-block · matplotlib/matplotlib@a7ecb9c · GitHub
[go: up one dir, main page]

Skip to content

Commit 10000 a7ecb9c

Browse files
authored
Merge pull request #25496 from dnicolodi/fix-ipython-block
BUG: fix IPython's %pylab mode detection
2 parents 80d72cb + f0671ca commit a7ecb9c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,8 +2930,8 @@ def pyplot_show(cls, *, block=None):
29302930
# Hack: Are we in IPython's %pylab mode? In pylab mode, IPython
29312931
# (>= 0.10) tacks a _needmain attribute onto pyplot.show (always
29322932
# set to False).
2933-
ipython_pylab = hasattr(
2934-
getattr(sys.modules.get("pyplot"), "show", None), "_needmain")
2933+
pyplot_show = getattr(sys.modules.get("matplotlib.pyplot"), "show", None)
2934+
ipython_pylab = hasattr(pyplot_show, "_needmain")
29352935
block = not ipython_pylab and not is_interactive()
29362936
if block:
29372937
cls.start_main_loop()
@@ -3645,8 +3645,8 @@ def show(cls, *, block=None):
36453645
# Hack: Are we in IPython's %pylab mode? In pylab mode, IPython
36463646
# (>= 0.10) tacks a _needmain attribute onto pyplot.show (always
36473647
# set to False).
3648-
ipython_pylab = hasattr(
3649-
getattr(sys.modules.get("pyplot"), "show", None), "_needmain")
3648+
pyplot_show = getattr(sys.modules.get("matplotlib.pyplot"), "show", None)
3649+
ipython_pylab = hasattr(pyplot_show, "_needmain")
36503650
block = not ipython_pylab and not is_interactive()
36513651
if block:
36523652
cls.mainloop()

0 commit comments

Comments
 (0)
0