8000 Merge pull request #21574 from meeseeksmachine/auto-backport-of-pr-21… · matplotlib/matplotlib@f855dde · GitHub
[go: up one dir, main page]

Skip to content

Commit f855dde

Browse files
authored
Merge pull request #21574 from meeseeksmachine/auto-backport-of-pr-21570-on-v3.4.x
Backport PR #21570 on branch v3.4.x (Raise correct exception out of Spines.__getattr__)
2 parents 6510bc4 + 63cc389 commit f855dde

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/matplotlib/spines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def __getattr__(self, name):
550550
try:
551551
return self._dict[name]
552552
except KeyError:
553-
raise ValueError(
553+
raise AttributeError(
554554
f"'Spines' object does not contain a '{name}' spine")
555555

556556
def __getitem__(self, key):

lib/matplotlib/tests/test_spines.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def set_val(self, val):
3535
spines[:].set_val('y')
3636
assert all(spine.val == 'y' for spine in spines.values())
3737

38+
with pytest.raises(AttributeError, match='foo'):
39+
spines.foo
3840
with pytest.raises(KeyError, match='foo'):
3941
spines['foo']
4042
with pytest.raises(KeyError, match='foo, bar'):

0 commit comments

Comments
 (0)
0