Skip to content

Fix: Gracefully fail the string validator for tuple inputs #24600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2022
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: 1 addition & 1 deletion lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __call__(self, s):
name, = (k for k, v in globals().items() if v is self)
_api.warn_deprecated(
self._deprecated_since, name=name, obj_type="function")
if self.ignorecase:
if self.ignorecase and isinstance(s, str):
s = s.lower()
if s in self.valid:
return self.valid[s]
Expand Down
8 changes: 8 additions & 0 deletions lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
import os
from pathlib import Path
import re
import subprocess
import sys
from unittest import mock
Expand Down Expand Up @@ -591,3 +592,10 @@ def test_deprecation(monkeypatch):
# Note that the warning suppression actually arises from the
# iteration over the updater rcParams being protected by
# suppress_matplotlib_deprecation_warning, rather than any explicit check.


def test_rcparams_legend_loc():
value = (0.9, .7)
match_str = f"{value} is not a valid value for legend.loc;"
with pytest.raises(ValueError, match=re.escape(match_str)):
mpl.RcParams({'legend.loc': value})