8000 Gracefully fail the string validator for tuple inputs · matplotlib/matplotlib@ff79f01 · GitHub
[go: up one dir, main page]

Skip to content

Commit ff79f01

Browse files
committed
Gracefully fail the string validator for tuple inputs
Partially closes - #22338
1 parent 7f7dfc9 commit ff79f01

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __call__(self, s):
6868
name, = (k for k, v in globals().items() if v is self)
6969
_api.warn_deprecated(
7070
self._deprecated_since, name=name, obj_type="function")
71-
if self.ignorecase:
71+
if self.ignorecase and isinstance(s, str):
7272
s = s.lower()
7373
if s in self.valid:
7474
return self.valid[s]

lib/matplotlib/tests/test_rcparams.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import copy
22
import os
33
from pathlib import Path
4+
import re
45
import subprocess
56
import sys
67
from unittest import mock
@@ -591,3 +592,10 @@ def test_deprecation(monkeypatch):
591592
# Note that the warning suppression actually arises from the
592593
# iteration over the updater rcParams being protected by
593594
# suppress_matplotlib_deprecation_warning, rather than any explicit check.
595+
596+
597+
def test_rcparams_legend_loc():
598+
value = (0.9, .7)
599+
match_str = f"{value} is not a valid value for legend.loc;"
600+
with pytest.raises(ValueError, match=re.escape(match_str)):
601+
mpl.RcParams({'legend.loc': value})

0 commit comments

Comments
 (0)
0