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 42f779e

Browse filesBrowse files
authored
Merge pull request #11950 from meeseeksmachine/auto-backport-of-pr-11934-on-v3.0.x
Backport PR #11934 on branch v3.0.x
2 parents c6b2056 + 19351e6 commit 42f779e
Copy full SHA for 42f779e

File tree

Expand file treeCollapse file tree

2 files changed

+13
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-6
lines changed

‎lib/matplotlib/sphinxext/plot_directive.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/plot_directive.py
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
import jinja2 # Sphinx dependency.
157157

158158
import matplotlib
159+
from matplotlib.backend_bases import FigureManagerBase
159160
try:
160161
with warnings.catch_warnings(record=True):
161162
warnings.simplefilter("error", UserWarning)
@@ -492,9 +493,13 @@ def run_code(code, code_path, ns=None, function_name=None):
492493
exec(str(setup.config.plot_pre_code), ns)
493494
if "__main__" in code:
494495
ns['__name__'] = '__main__'
495-
exec(code, ns)
496-
if function_name is not None:
497-
exec(function_name + "()", ns)
496+
497+
# Patch out non-interactive show() to avoid triggering a warning.
498+
with cbook._setattr_cm(FigureManagerBase, show=lambda self: None):
499+
exec(code, ns)
500+
if function_name is not None:
501+
exec(function_name + "()", ns)
502+
498503
except (Exception, SystemExit) as err:
499504
raise PlotError(traceback.format_exc())
500505
finally:

‎lib/matplotlib/sphinxext/tests/test_tinypages.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/tests/test_tinypages.py
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ def test_tinypages(tmpdir):
1919
# Build the pages with warnings turned into errors
2020
cmd = [sys.executable, '-msphinx', '-W', '-b', 'html', '-d', doctree_dir,
2121
pjoin(dirname(__file__), 'tinypages'), html_dir]
22-
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
22+
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
2323
out, err = proc.communicate()
2424
assert proc.returncode == 0, \
25-
"'{} -msphinx' failed with stdout:\n{}\nstderr:\n{}\n".format(
26-
sys.executable, out, err)
25+
"sphinx build failed with stdout:\n{}\nstderr:\n{}\n".format(out, err)
26+
if err:
27+
pytest.fail("sphinx build emitted the following warnings:\n{}"
28+
.format(err))
2729

2830
assert isdir(html_dir)
2931

0 commit comments

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