Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fb8d773

Browse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR #25496: BUG: fix IPython's %pylab mode detection
1 parent 9e42778 commit fb8d773

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
@@ -2898,8 +2898,8 @@ def pyplot_show(cls, *, block=None):
28982898
# Hack: Are we in IPython's %pylab mode? In pylab mode, IPython
28992899
# (>= 0.10) tacks a _needmain attribute onto pyplot.show (always
29002900
# set to False).
2901-
ipython_pylab = hasattr(
2902-
getattr(sys.modules.get("pyplot"), "show", None), "_needmain")
2901+
pyplot_show = getattr(sys.modules.get("matplotlib.pyplot"), "show", None)
2902+
ipython_pylab = hasattr(pyplot_show, "_needmain")
29032903
block = not ipython_pylab and not is_interactive()
29042904
if block:
29052905
cls.start_main_loop()
@@ -3613,8 +3613,8 @@ def show(cls, *, block=None):
36133613
# Hack: Are we in IPython's %pylab mode? In pylab mode, IPython
36143614
# (>= 0.10) tacks a _needmain attribute onto pyplot.show (always
36153615
# set to False).
3616-
ipython_pylab = hasattr(
3617-
getattr(sys.modules.get("pyplot"), "show", None), "_needmain")
3616+
pyplot_show = getattr(sys.modules.get("matplotlib.pyplot"), "show", None)
3617+
ipython_pylab = hasattr(pyplot_show, "_needmain")
36183618
block = not ipython_pylab and not is_interactive()
36193619
if block:
36203620
cls.mainloop()

0 commit comments

Comments
 (0)