Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit72a3962

Browse files
ksundenmeeseeksmachine
authored andcommitted
Backport PRmatplotlib#26689: Fix error generation for missing pgf.texsystem.
1 parent227825e commit72a3962

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

‎lib/matplotlib/backends/backend_pgf.py

Lines 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-
exceptFileNotFoundErroraserr:
247-
raiseRuntimeError(
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.")fromerr
251-
exceptOSErroraserr:
252-
raiseRuntimeError(
253-
f"Error starting process{self.latex.args[0]!r}")fromerr
244+
self._setup_latex_process(expect_reply=False)
254245
stdout,stderr=self.latex.communicate("\n\\makeatletter\\@@end\n")
255246
ifself.latex.returncode!=0:
256247
raiseLatexError(
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+
exceptFileNotFoundErroraserr:
267+
raiseRuntimeError(
268+
f"{mpl.rcParams['pgf.texsystem']!r} not found; install it or change "
269+
f"rcParams['pgf.texsystem'] to an available TeX implementation"
270+
)fromerr
271+
exceptOSErroraserr:
272+
raiseRuntimeError(
273+
f"Error starting{mpl.rcParams['pgf.texsystem']!r}")fromerr
275274

276275
deffinalize_latex(latex):
277276
latex.kill()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp