Skip to content

Commit 2c8dada

Browse files
authored
Merge pull request #25277 from ksunden/auto-backport-of-pr-25268-on-v3.7.x
Backport PR #25268 on branch v3.7.x (Fix import of styles with relative path)
2 parents c70ddbc + 0b9441d commit 2c8dada

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/matplotlib/style/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def use(style):
153153
path = (importlib_resources.files(pkg)
154154
/ f"{name}.{STYLE_EXTENSION}")
155155
style = _rc_params_in_file(path)
156-
except (ModuleNotFoundError, IOError) as exc:
156+
except (ModuleNotFoundError, OSError, TypeError) as exc:
157157
# There is an ambiguity whether a dotted name refers to a
158158
# package.style_name or to a dotted file path. Currently,
159159
# we silently try the first form and then the second one;

lib/matplotlib/tests/test_style.py

+2
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,5 @@ def test_style_from_module(tmp_path, monkeypatch):
205205
assert mpl.rcParams["lines.linewidth"] == 42
206206
mpl.style.use("mpl_test_style_pkg.mplstyle")
207207
assert mpl.rcParams["lines.linewidth"] == 84
208+
mpl.style.use("./mpl_test_style_pkg.mplstyle")
209+
assert mpl.rcParams["lines.linewidth"] == 84

0 commit comments

Comments
 (0)