Skip to content

Commit dd76b3f

Browse files
bpo-46246: add missing __slots__ to importlib.metadata.DeprecatedList (GH-30452)
Confirmed with @jaraco that this indeed needs a fix. A question that came up while I was digging into the code: I think `SelectableGroups` could similarly use `__slots__ = ()`, since its purpose seems only for convenience around `dict`, not to have attributes of its own. Automerge-Triggered-By: GH:jaraco
1 parent 80e4f26 commit dd76b3f

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Lib/importlib/metadata/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ class DeprecatedList(list):
278278
1
279279
"""
280280

281+
__slots__ = ()
282+
281283
_warn = functools.partial(
282284
warnings.warn,
283285
"EntryPoints list interface is deprecated. Cast to list if needed.",

Lib/test/test_importlib/test_metadata_api.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ def test_entry_points_groups_get(self):
172172
entry_points().get('entries', 'default') == entry_points()['entries']
173173
entry_points().get('missing', ()) == ()
174174

175+
def test_entry_points_allows_no_attributes(self):
176+
ep = entry_points().select(group='entries', name='main')
177+
with self.assertRaises(AttributeError):
178+
ep.foo = 4
179+
175180
def test_metadata_for_this_package(self):
176181
md = metadata('egginfo-pkg')
177182
assert md['author'] == 'Steven Ma'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add missing ``__slots__`` to ``importlib.metadata.DeprecatedList``. Patch by
2+
Arie Bovenberg.

0 commit comments

Comments
 (0)