]> granicus.if.org Git - python/commitdiff
add a test and a note about metaclasses now being abcs
authorBenjamin Peterson <benjamin@python.org>
Sat, 2 Oct 2010 17:55:47 +0000 (17:55 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sat, 2 Oct 2010 17:55:47 +0000 (17:55 +0000)
Lib/test/test_abc.py
Misc/NEWS

index 3a1d76b903417bf981e6609c07fc93cb7228236e..1b516445f205e70719cf506811db62b7c4a4fe15 100644 (file)
@@ -105,6 +105,19 @@ class TestABC(unittest.TestCase):
             pass
         self.assertRaises(AttributeError, getattr, meta, "__abstractmethods__")
 
+    def test_metaclass_abc(self):
+        # Metaclasses can be ABCs, too.
+        class A(metaclass=abc.ABCMeta):
+            @abc.abstractmethod
+            def x(self):
+                pass
+        self.assertEqual(A.__abstractmethods__, {"x"})
+        class meta(type, A):
+            def x(self):
+                return 1
+        class C(metaclass=meta):
+            pass
+
     def test_registration_basics(self):
         class A(metaclass=abc.ABCMeta):
             pass
index 2a6d494cf5900de06bcc5254a6dd831175a0cb24..c5d1e62c1951606ec2203d2f58b8c87a9df7c984 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,14 +10,15 @@ What's New in Python 3.2 Alpha 3?
 Core and Builtins
 -----------------
 
+- Issue #10006: type.__abstractmethods__ now raises an AttributeError.  As a
+  result metaclasses can now be ABCs (see #9533).
+
 - Issue #8670: ctypes.c_wchar supports non-BMP characters with 32 bits wchar_t.
 
 - Issue #8670: PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() replace
   UTF-16 surrogate pairs by single non-BMP characters for 16 bits Py_UNICODE
   and 32 bits wchar_t (eg. Linux in narrow build).
 
-- Issue #10006: type.__abstractmethods__ now raises an AttributeError.
-
 - Issue #10003: Allow handling of SIGBREAK on Windows. Fixes a regression
   introduced by issue #9324.