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

Skip to content

Commit 52a5dfd

Browse files
jsjeelshahQuLogic
authored andcommitted
Remove deprecated code from _fontconfig_patterns
1 parent e5098e0 commit 52a5dfd

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``parse_fontconfig_pattern`` raises on unknown constant names
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Previously, in a fontconfig pattern like ``DejaVu Sans:foo``, the unknown
5+
``foo`` constant name would be silently ignored. This now raises an error.

lib/matplotlib/_fontconfig_pattern.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
import re
1414

1515
from pyparsing import (
16-
Group, Optional, ParseException, Regex, StringEnd, Suppress, ZeroOrMore)
17-
18-
from matplotlib import _api
16+
Optional, ParseException, Regex, StringEnd, Suppress, ZeroOrMore, oneOf)
1917

2018

2119
_family_punc = r'\\\-:,'
@@ -63,8 +61,7 @@ def comma_separated(elem):
6361
size = Regex(r"([0-9]+\.?[0-9]*|\.[0-9]+)")
6462
name = Regex(r"[a-z]+")
6563
value = Regex(fr"([^{_value_punc}]|(\\[{_value_punc}]))*")
66-
# replace trailing `| name` by oneOf(_CONSTANTS) in mpl 3.9.
67-
prop = Group((name + Suppress("=") + comma_separated(value)) | name)
64+
prop = (name + Suppress("=") + comma_separated(value)) | oneOf(_CONSTANTS)
6865
return (
6966
Optional(comma_separated(family)("families"))
7067
+ Optional("-" + comma_separated(size)("sizes"))
@@ -97,12 +94,6 @@ def parse_fontconfig_pattern(pattern):
9794
props["size"] = [*parse["sizes"]]
9895
for prop in parse.get("properties", []):
9996
if len(prop) == 1:
100-
if prop[0] not in _CONSTANTS:
101-
_api.warn_deprecated(
102-
"3.7", message=f"Support for unknown constants "
103-
f"({prop[0]!r}) is deprecated since %(since)s and "
104-
f"will be removed %(removal)s.")
105-
continue
10697
prop = _CONSTANTS[prop[0]]
10798
k, *v = prop
10899
props.setdefault(k, []).extend(map(_value_unescape, v))

lib/matplotlib/tests/test_fontconfig_pattern.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ def test_fontconfig_str():
7373

7474

7575
def test_fontconfig_unknown_constant():
76-
with pytest.warns(DeprecationWarning):
76+
with pytest.raises(ValueError, match="ParseException"):
7777
FontProperties(":unknown")

0 commit comments

Comments
 (0)