Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 35ec03c

Browse filesBrowse files
authored
Tweak check for IPython pylab mode. (#23097)
We really only care about whether the attribute is present (even nowadays, _needmain is always False; it appears to never have changed in IPython's history).
1 parent feb1ca1 commit 35ec03c
Copy full SHA for 35ec03c

File tree

Expand file treeCollapse file tree

1 file changed

+4
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-7
lines changed

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3498,14 +3498,11 @@ def show(cls, *, block=None):
34983498
if cls.mainloop is None:
34993499
return
35003500
if block is None:
3501-
# Hack: Are we in IPython's pylab mode?
3501+
# Hack: Are we in IPython's %pylab mode? In pylab mode, IPython
3502+
# (>= 0.10) tacks a _needmain attribute onto pyplot.show (always
3503+
# set to False).
35023504
from matplotlib import pyplot
3503-
try:
3504-
# IPython versions >= 0.10 tack the _needmain attribute onto
3505-
# pyplot.show, and always set it to False, when in %pylab mode.
3506-
ipython_pylab = not pyplot.show._needmain
3507-
except AttributeError:
3508-
ipython_pylab = False
3505+
ipython_pylab = hasattr(pyplot.show, "_needmain")
35093506
block = not ipython_pylab and not is_interactive()
35103507
# TODO: The above is a hack to get the WebAgg backend working with
35113508
# ipython's `%pylab` mode until proper integration is implemented.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.