From bcfa537ee0159d0cb402a2f4751ed50dfe4bd659 Mon Sep 17 00:00:00 2001 From: Jason Madden Date: Tue, 7 Apr 2020 09:23:10 -0500 Subject: Minor cleanup of #202. See https://github.com/zopefoundation/zope.interface/pull/202#pullrequestreview-389126705 --- src/zope/interface/common/__init__.py | 13 +++++++++++-- 1 file 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() -- cgit v1.2.1