Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b19794e

Browse filesBrowse files
authored
Merge pull request #28388 from ianthomas23/28367_allow_identical_name_value_entry_points
Allow duplicate (name, value) entry points for backends
2 parents 54729db + 5a55b88 commit b19794e
Copy full SHA for b19794e

File tree

2 files changed

+16
-2
lines changed
Filter options

2 files changed

+16
-2
lines changed

‎lib/matplotlib/backends/registry.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/registry.py
+5-2Lines changed: 5 additions & 2 deletions
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

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_registry.py
+11Lines changed: 11 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.