summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2020-04-07 09:23:10 -0500
committerJason Madden <jamadden@gmail.com>2020-04-07 09:23:10 -0500
commitbcfa537ee0159d0cb402a2f4751ed50dfe4bd659 (patch)
treefbe135016fc90ac0c093da7b94bebc433126c552
parenta404e5fed4766625b564de558942dd4efd979e89 (diff)
downloadzope-interface-issue3_minor_cleanup.tar.gz
Minor cleanup of #202.issue3_minor_cleanup
See https://github.com/zopefoundation/zope.interface/pull/202#pullrequestreview-389126705
-rw-r--r--src/zope/interface/common/__init__.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/zope/interface/common/__init__.py b/src/zope/interface/common/__init__.py
index 01f0bd3..137e938 100644
--- a/src/zope/interface/common/__init__.py
+++ b/src/zope/interface/common/__init__.py
@@ -259,5 +259,14 @@ class ABCInterfaceClass(InterfaceClass):
return set(itertools.chain(registered, self.__extra_classes))
-ABCInterface = ABCInterfaceClass.__new__(ABCInterfaceClass, 'ABCInterface', (), {})
-InterfaceClass.__init__(ABCInterface, 'ABCInterface', (Interface,), {})
+def _create_ABCInterface():
+ # It's a two-step process to create the root ABCInterface, because
+ # without specifying a corresponding ABC, using the normal constructor
+ # gets us a plain InterfaceClass object, and there is no ABC to associate with the
+ # root.
+ abc_name_bases_attrs = ('ABCInterface', (Interface,), {})
+ instance = ABCInterfaceClass.__new__(ABCInterfaceClass, *abc_name_bases_attrs)
+ InterfaceClass.__init__(instance, *abc_name_bases_attrs)
+ return instance
+
+ABCInterface = _create_ABCInterface()