Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b9441d

Browse files
oscargusksunden
authored andcommitted
Backport PR #25268 on branch v3.7.x (Fix import of styles with relative path)
Fix import of styles with relative path (cherry picked from commit ee7d75e) Conflict was caused by pyupgrade changing IOError to OSError (which are aliases of each other since py3.3)
1 parent 8099c7d commit 0b9441d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/matplotlib/style/core.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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)