Skip to content

Commit ff48739

Browse files
aaronchallserhiy-storchaka
authored andcommitted
bpo-30463: Add an empty __slots__ to abc.ABC.
1 parent ec19ba2 commit ff48739

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

Lib/abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class ABC(metaclass=ABCMeta):
235235
"""Helper class that provides a standard way to create an ABC using
236236
inheritance.
237237
"""
238-
pass
238+
__slots__ = ()
239239

240240

241241
def get_cache_token():

Lib/test/test_abc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ class C(A, B):
402402
C()
403403
self.assertEqual(B.counter, 1)
404404

405+
def test_ABC_has___slots__(self):
406+
self.assertTrue(hasattr(abc.ABC, '__slots__'))
407+
405408

406409
class TestABCWithInitSubclass(unittest.TestCase):
407410
def test_works_with_init_subclass(self):

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ Extension Modules
345345
Library
346346
-------
347347

348+
- bpo-30463: Addded empty __slots__ to abc.ABC. This allows subclassers
349+
to deny __dict__ and __weakref__ creation. Patch by Aaron Hall.
350+
348351
- bpo-30520: Loggers are now pickleable.
349352

350353
- bpo-30557: faulthandler now correctly filters and displays exception codes

0 commit comments

Comments
 (0)