From: Aaron Hall, MBA <aaronchall@yahoo.com> Date: Tue, 6 Jun 2017 19:34:57 +0000 (-0400) Subject: bpo-30463: Add an empty __slots__ to abc.ABC. X-Git-Tag: v3.7.0a1~677 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff48739ed0a3f366c4d56d3c86a37cbdeec600de;p=python bpo-30463: Add an empty __slots__ to abc.ABC. --- diff --git a/Lib/abc.py b/Lib/abc.py index 43a34a0bbd..d13a0de89b 100644 --- a/Lib/abc.py +++ b/Lib/abc.py @@ -235,7 +235,7 @@ class ABC(metaclass=ABCMeta): """Helper class that provides a standard way to create an ABC using inheritance. """ - pass + __slots__ = () def get_cache_token(): diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py index e20e033f21..61c2876708 100644 --- a/Lib/test/test_abc.py +++ b/Lib/test/test_abc.py @@ -402,6 +402,9 @@ class TestABC(unittest.TestCase): C() self.assertEqual(B.counter, 1) + def test_ABC_has___slots__(self): + self.assertTrue(hasattr(abc.ABC, '__slots__')) + class TestABCWithInitSubclass(unittest.TestCase): def test_works_with_init_subclass(self): diff --git a/Misc/NEWS b/Misc/NEWS index 4b0879bee2..f043832e67 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -345,6 +345,9 @@ Extension Modules Library ------- +- bpo-30463: Addded empty __slots__ to abc.ABC. This allows subclassers + to deny __dict__ and __weakref__ creation. Patch by Aaron Hall. + - bpo-30520: Loggers are now pickleable. - bpo-30557: faulthandler now correctly filters and displays exception codes