summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2020-01-27 16:20:19 -0600
committerJason Madden <jamadden@gmail.com>2020-01-27 16:20:19 -0600
commit7a9924b85a1ddcc54cfd3c5d47f51f358dbeda0b (patch)
tree5026aa660bb6f5c3b15f381e26698e49ce74eb30
parent61c6d54ebad0cce407169a27f7a199fc80fdc03a (diff)
downloadzope-interface-7a9924b85a1ddcc54cfd3c5d47f51f358dbeda0b.tar.gz
Add comment detailing why __bases__ can be set per review.issue158
-rw-r--r--src/zope/interface/declarations.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/zope/interface/declarations.py b/src/zope/interface/declarations.py
index f8337a1..83f424c 100644
--- a/src/zope/interface/declarations.py
+++ b/src/zope/interface/declarations.py
@@ -136,7 +136,13 @@ class _ImmutableDeclaration(Declaration):
@__bases__.setter
def __bases__(self, new_bases):
- if new_bases:
+ # We expect the superclass constructor to set ``self.__bases__ = ()``.
+ # Rather than attempt to special case that in the constructor and allow
+ # setting __bases__ only at that time, it's easier to just allow setting
+ # the empty tuple at any time. That makes ``x.__bases__ = x.__bases__`` a nice
+ # no-op too. (Skipping the superclass constructor altogether is a recipe
+ # for maintenance headaches.)
+ if new_bases != ():
raise TypeError("Cannot set non-empty bases on shared empty Declaration.")
@property