diff --git a/lib/matplotlib/tests/test_texmanager.py b/lib/matplotlib/tests/test_texmanager.py index 29ed9d86597f..fbff21144e60 100644 --- a/lib/matplotlib/tests/test_texmanager.py +++ b/lib/matplotlib/tests/test_texmanager.py @@ -1,5 +1,8 @@ +import os from pathlib import Path import re +import subprocess +import sys import matplotlib.pyplot as plt from matplotlib.texmanager import TexManager @@ -57,3 +60,15 @@ def test_unicode_characters(): with pytest.raises(RuntimeError): ax.set_title('\N{SNOWMAN}') fig.canvas.draw() + + +@needs_usetex +def test_openin_any_paranoid(): + completed = subprocess.run( + [sys.executable, "-c", + 'import matplotlib.pyplot as plt;' + 'plt.rcParams.update({"text.usetex": True});' + 'plt.title("paranoid");' + 'plt.show(block=False);'], + env={**os.environ, 'openin_any': 'p'}, check=True, capture_output=True) + assert completed.stderr == b"" diff --git a/lib/matplotlib/texmanager.py b/lib/matplotlib/texmanager.py index edac2fec9c79..c0d37edbc3d8 100644 --- a/lib/matplotlib/texmanager.py +++ b/lib/matplotlib/texmanager.py @@ -291,12 +291,16 @@ def make_dvi(cls, tex, fontsize): # and thus replace() works atomically. It also allows referring to # the texfile with a relative path (for pathological MPLCONFIGDIRs, # the absolute path may contain characters (e.g. ~) that TeX does - # not support.) - with TemporaryDirectory(dir=Path(dvifile).parent) as tmpdir: + # not support; n.b. relative paths cannot traverse parents, or it + # will be blocked when `openin_any = p` in texmf.cnf). + cwd = Path(dvifile).parent + with TemporaryDirectory(dir=cwd) as tmpdir: + tmppath = Path(tmpdir) cls._run_checked_subprocess( ["latex", "-interaction=nonstopmode", "--halt-on-error", - f"../{texfile.name}"], tex, cwd=tmpdir) - (Path(tmpdir) / Path(dvifile).name).replace(dvifile) + f"--output-directory={tmppath.name}", + f"{texfile.name}"], tex, cwd=cwd) + (tmppath / Path(dvifile).name).replace(dvifile) return dvifile @classmethod
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: