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 1407a4a

Browse filesBrowse files
authored
Merge pull request #26694 from meeseeksmachine/auto-backport-of-pr-26689-on-v3.8.x
Backport PR #26689 on branch v3.8.x (Fix error generation for missing pgf.texsystem.)
2 parents 227825e + 72a3962 commit 1407a4a
Copy full SHA for 1407a4a

File tree

1 file changed

+14
-15
lines changed
Filter options

1 file changed

+14
-15
lines changed

‎lib/matplotlib/backends/backend_pgf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pgf.py
+14-15Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -241,24 +241,14 @@ def __init__(self):
241241
self._finalize_tmpdir = weakref.finalize(self, self._tmpdir.cleanup)
242242

243243
# test the LaTeX setup to ensure a clean startup of the subprocess
244-
try:
245-
self._setup_latex_process(expect_reply=False)
246-
except FileNotFoundError as err:
247-
raise RuntimeError(
248-
f"{self.latex.args[0]!r} not found. Install it or change "
249-
f"rcParams['pgf.texsystem'] to an available TeX "
250-
f"implementation.") from err
251-
except OSError as err:
252-
raise RuntimeError(
253-
f"Error starting process {self.latex.args[0]!r}") from err
244+
self._setup_latex_process(expect_reply=False)
254245
stdout, stderr = self.latex.communicate("\n\\makeatletter\\@@end\n")
255246
if self.latex.returncode != 0:
256247
raise LatexError(
257248
f"LaTeX errored (probably missing font or error in preamble) "
258249
f"while processing the following input:\n"
259250
f"{self._build_latex_header()}",
260251
stdout)
261-
262252
self.latex = None # Will be set up on first use.
263253
# Per-instance cache.
264254
self._get_box_metrics = functools.lru_cache(self._get_box_metrics)
@@ -268,10 +258,19 @@ def _setup_latex_process(self, *, expect_reply=True):
268258
# Windows, we must ensure that the subprocess has quit before being
269259
# able to delete the tmpdir in which it runs; in order to do so, we
270260
# must first `kill()` it, and then `communicate()` with it.
271-
self.latex = subprocess.Popen(
272-
[mpl.rcParams["pgf.texsystem"], "-halt-on-error"],
273-
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
274-
encoding="utf-8", cwd=self.tmpdir)
261+
try:
262+
self.latex = subprocess.Popen(
263+
[mpl.rcParams["pgf.texsystem"], "-halt-on-error"],
264+
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
265+
encoding="utf-8", cwd=self.tmpdir)
266+
except FileNotFoundError as err:
267+
raise RuntimeError(
268+
f"{mpl.rcParams['pgf.texsystem']!r} not found; install it or change "
269+
f"rcParams['pgf.texsystem'] to an available TeX implementation"
270+
) from err
271+
except OSError as err:
272+
raise RuntimeError(
273+
f"Error starting {mpl.rcParams['pgf.texsystem']!r}") from err
275274

276275
def finalize_latex(latex):
277276
latex.kill()

0 commit comments

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