Skip to content

Commit 5624621

Browse files
authored
Merge pull request matplotlib#28392 from meeseeksmachine/auto-backport-of-pr-28388-on-v3.9.x
Backport PR matplotlib#28388 on branch v3.9.x (Allow duplicate (name, value) entry points for backends)
2 parents 0e37092 + 0ffc8c1 commit 5624621

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/matplotlib/backends/registry.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,11 @@ def backward_compatible_entry_points(
168168
def _validate_and_store_entry_points(self, entries):
169169
# Validate and store entry points so that they can be used via matplotlib.use()
170170
# in the normal manner. Entry point names cannot be of module:// format, cannot
171-
# shadow a built-in backend name, and cannot be duplicated.
172-
for name, module in entries:
171+
# shadow a built-in backend name, and there cannot be multiple entry points
172+
# with the same name but different modules. Multiple entry points with the same
173+
# name and value are permitted (it can sometimes happen outside of our control,
174+
# see https://github.com/matplotlib/matplotlib/issues/28367).
175+
for name, module in set(entries):
173176
name = name.lower()
174177
if name.startswith("module://"):
175178
raise RuntimeError(

lib/matplotlib/tests/test_backend_registry.py

+11
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,17 @@ def test_entry_point_name_duplicate(clear_backend_registry):
121121
[('some_name', 'module1'), ('some_name', 'module2')])
122122

123123

124+
def test_entry_point_identical(clear_backend_registry):
125+
# Issue https://github.com/matplotlib/matplotlib/issues/28367
126+
# Multiple entry points with the same name and value (value is the module)
127+
# are acceptable.
128+
n = len(backend_registry._name_to_module)
129+
backend_registry._validate_and_store_entry_points(
130+
[('some_name', 'some.module'), ('some_name', 'some.module')])
131+
assert len(backend_registry._name_to_module) == n+1
132+
assert backend_registry._name_to_module['some_name'] == 'module://some.module'
133+
134+
124135
def test_entry_point_name_is_module(clear_backend_registry):
125136
with pytest.raises(RuntimeError):
126137
backend_registry._validate_and_store_entry_points(

0 commit comments

Comments
 (0)