From 55f4e2af6c1f5931cbd526b7f9f06d5d037ffa63 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 20 Feb 2023 17:35:11 +0000 Subject: [PATCH 1/2] tests: failing test for local style import with ./ in name added. --- lib/matplotlib/tests/test_style.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/matplotlib/tests/test_style.py b/lib/matplotlib/tests/test_style.py index b08930ef02cd..abeb1510a31a 100644 --- a/lib/matplotlib/tests/test_style.py +++ b/lib/matplotlib/tests/test_style.py @@ -205,3 +205,5 @@ def test_style_from_module(tmp_path, monkeypatch): assert mpl.rcParams["lines.linewidth"] == 42 mpl.style.use("mpl_test_style_pkg.mplstyle") assert mpl.rcParams["lines.linewidth"] == 84 + mpl.style.use("./mpl_test_style_pkg.mplstyle") + assert mpl.rcParams["lines.linewidth"] == 84 From e92a8cf161b41f521d58d0032e19ac962668ec5c Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 20 Feb 2023 17:35:46 +0000 Subject: [PATCH 2/2] fix: import of local style with ./ in name fixed. --- lib/matplotlib/style/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/style/core.py b/lib/matplotlib/style/core.py index 04daca1ce471..a56b5347ac37 100644 --- a/lib/matplotlib/style/core.py +++ b/lib/matplotlib/style/core.py @@ -153,7 +153,7 @@ def use(style): path = (importlib_resources.files(pkg) / f"{name}.{STYLE_EXTENSION}") style = _rc_params_in_file(path) - except (ModuleNotFoundError, OSError) as exc: + except (ModuleNotFoundError, OSError, TypeError) as exc: # There is an ambiguity whether a dotted name refers to a # package.style_name or to a dotted file path. Currently, # we silently try the first form and then the second one;