Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/api/next_api_changes/deprecations/20474-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``dviread.PsfontsMap`` now raises LookupError instead of KeyError for missing fonts
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 changes: 6 additions & 9 deletions lib/matplotlib/dviread.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import struct
import subprocess
import sys
import textwrap

import numpy as np

Expand Down Expand Up @@ -852,14 +851,12 @@ def __getitem__(self, texname):
try:
return self._parsed[texname]
except KeyError:
fmt = ('An associated PostScript font (required by Matplotlib) '
'could not be found for TeX font {0!r} in {1!r}. This '
'problem can often be solved by installing a suitable '
'PostScript font package in your TeX package manager.')
_log.info(textwrap.fill(
fmt.format(texname.decode('ascii'), self._filename),
break_on_hyphens=False, break_long_words=False))
raise
raise LookupError(
f"An associated PostScript font (required by Matplotlib) "
f"could not be found for TeX font {texname.decode('ascii')!r} "
f"in {self._filename!r}; this problem can often be solved by "
f"installing a suitable PostScript font package in your TeX "
f"package manager") from None

def _parse_and_cache_line(self, line):
"""
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_dviread.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def test_PsfontsMap(monkeypatch):
entry = fontmap[b'TeXfontC']
assert entry.psname == b'PSfontC3'
# Missing font
with pytest.raises(KeyError, match='no-such-font'):
with pytest.raises(LookupError, match='no-such-font'):
fontmap[b'no-such-font']
with pytest.raises(KeyError, match='%'):
with pytest.raises(LookupError, match='%'):
fontmap[b'%']


Expand Down