Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 64bcdc4

Browse filesBrowse files
authored
Merge pull request #23037 from anntzer/fpc
Suppress exception chaining in FontProperties.
2 parents 6c79f81 + c654b9c commit 64bcdc4
Copy full SHA for 64bcdc4

File tree

Expand file treeCollapse file tree

1 file changed

+18
-10
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-10
lines changed

‎lib/matplotlib/font_manager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/font_manager.py
+18-10Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -860,14 +860,18 @@ def set_weight(self, weight):
860860
"""
861861
if weight is None:
862862
weight = rcParams['font.weight']
863+
if weight in weight_dict:
864+
self._weight = weight
865+
return
863866
try:
864867
weight = int(weight)
865-
if weight < 0 or weight > 1000:
866-
raise ValueError()
867868
except ValueError:
868-
if weight not in weight_dict:
869-
raise ValueError("weight is invalid")
870-
self._weight = weight
869+
pass
870+
else:
871+
if 0 <= weight <= 1000:
872+
self._weight = weight
873+
return
874+
raise ValueError(f"{weight=} is invalid")
871875

872876
def set_stretch(self, stretch):
873877
"""
@@ -882,14 +886,18 @@ def set_stretch(self, stretch):
882886
"""
883887
if stretch is None:
884888
stretch = rcParams['font.stretch']
889+
if stretch in stretch_dict:
890+
self._stretch = stretch
891+
return
885892
try:
886893
stretch = int(stretch)
887-
if stretch < 0 or stretch > 1000:
888-
raise ValueError()
889894
except ValueError as err:
890-
if stretch not in stretch_dict:
891-
raise ValueError("stretch is invalid") from err
892-
self._stretch = stretch
895+
pass
896+
else:
897+
if 0 <= stretch <= 1000:
898+
self._stretch = stretch
899+
return
900+
raise ValueError(f"{stretch=} is invalid")
893901

894902
def set_size(self, size):
895903
"""

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.