]> granicus.if.org Git - python/commitdiff
bpo-30463: Add an empty __slots__ to abc.ABC.
authorAaron Hall, MBA <aaronchall@yahoo.com>
Tue, 6 Jun 2017 19:34:57 +0000 (15:34 -0400)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 6 Jun 2017 19:34:57 +0000 (22:34 +0300)
Lib/abc.py
Lib/test/test_abc.py
Misc/NEWS

index 43a34a0bbded7864987f57a855bf788c4b74138f..d13a0de89b4054e781a0bc0ffa4c6d8a73181149 100644 (file)
@@ -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():
index e20e033f219b7133e0211b361bc3125ea9109624..61c2876708c2567070e7ba791367c8b8fe101479 100644 (file)
@@ -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):
index 4b0879bee296eca6aa5b870598cf6a71a5923421..f043832e6703b7373788fc62207f208b0d7fe59b 100644 (file)
--- 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