Skip to content

Commit f8cf0ee

Browse files
authored
Merge pull request #23804 from jtracey/openout_any_paranoid
Fix TexManager's support for `openin_any = p`
2 parents 4ad86c8 + 19e6417 commit f8cf0ee

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

lib/matplotlib/tests/test_texmanager.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import os
12
from pathlib import Path
23
import re
4+
import subprocess
5+
import sys
36

47
import matplotlib.pyplot as plt
58
from matplotlib.texmanager import TexManager
@@ -57,3 +60,15 @@ def test_unicode_characters():
5760
with pytest.raises(RuntimeError):
5861
ax.set_title('\N{SNOWMAN}')
5962
fig.canvas.draw()
63+
64+
65+
@needs_usetex
66+
def test_openin_any_paranoid():
67+
completed = subprocess.run(
68+
[sys.executable, "-c",
69+
'import matplotlib.pyplot as plt;'
70+
'plt.rcParams.update({"text.usetex": True});'
71+
'plt.title("paranoid");'
72+
'plt.show(block=False);'],
73+
env={**os.environ, 'openin_any': 'p'}, check=True, capture_output=True)
74+
assert completed.stderr == b""

lib/matplotlib/texmanager.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,16 @@ def make_dvi(cls, tex, fontsize):
291291
# and thus replace() works atomically. It also allows referring to
292292
# the texfile with a relative path (for pathological MPLCONFIGDIRs,
293293
# the absolute path may contain characters (e.g. ~) that TeX does
294-
# not support.)
295-
with TemporaryDirectory(dir=Path(dvifile).parent) as tmpdir:
294+
# not support; n.b. relative paths cannot traverse parents, or it
295+
# will be blocked when `openin_any = p` in texmf.cnf).
296+
cwd = Path(dvifile).parent
297+
with TemporaryDirectory(dir=cwd) as tmpdir:
298+
tmppath = Path(tmpdir)
296299
cls._run_checked_subprocess(
297300
["latex", "-interaction=nonstopmode", "--halt-on-error",
298-
f"../{texfile.name}"], tex, cwd=tmpdir)
299-
(Path(tmpdir) / Path(dvifile).name).replace(dvifile)
301+
f"--output-directory={tmppath.name}",
302+
f"{texfile.name}"], tex, cwd=cwd)
303+
(tmppath / Path(dvifile).name).replace(dvifile)
300304
return dvifile
301305

302306
@classmethod

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy