Skip to content

Commit ae6e943

Browse files
committed
Improve error arising from fully commented-out TeX strings.
Currently, `figtext(.5, .5, "%foo", usetex=True)` results in an obscure exception (`FileNotFoundError: No such file or directory: blah.dvi`). Best would be to force TeX to always generate a page even if the string is "empty" (from TeX's PoV), but in the meantime, at least log a warning to make the situation slightly less confusing.
1 parent 7b6eb77 commit ae6e943

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/matplotlib/dviread.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,15 @@ def __init__(self, filename, dpi):
196196
Use None to return TeX's internal units.
197197
"""
198198
_log.debug('Dvi: %s', filename)
199-
self.file = open(filename, 'rb')
199+
try:
200+
self.file = open(filename, 'rb')
201+
except FileNotFoundError:
202+
# This warning should go away once we fix texmanager to always
203+
# create a dvi file, even if it is empty.
204+
_log.warning(
205+
'%s does not exist; this may arise from processing an empty '
206+
'or fully commented-out TeX string.', filename)
207+
raise
200208
self.dpi = dpi
201209
self.fonts = {}
202210
self.state = _dvistate.pre

0 commit comments

Comments
 (0)