diff options
Diffstat (limited to 'src/zope/interface/declarations.py')
-rw-r--r-- | src/zope/interface/declarations.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/zope/interface/declarations.py b/src/zope/interface/declarations.py index 935b026..0289ddc 100644 --- a/src/zope/interface/declarations.py +++ b/src/zope/interface/declarations.py @@ -1243,10 +1243,19 @@ def providedBy(ob): @_use_c_impl class ObjectSpecificationDescriptor(object): - """Implement the `__providedBy__` attribute - - The `__providedBy__` attribute computes the interfaces provided by - an object. + """Implement the ``__providedBy__`` attribute + + The ``__providedBy__`` attribute computes the interfaces provided by + an object. If an object has an ``__provides__`` attribute + + .. versionchanged:: 5.4.0 + Both the default (C) implementation and the Python implementation + now let exceptions raised by accessing ``__provides__`` propagate. + Previously, the C version ignored all exceptions. + .. versionchanged:: 5.4.0 + The Python implementation now matches the C implementation and lets + a ``__provides__`` of ``None`` override what the class is declared to + implement. """ def __get__(self, inst, cls): @@ -1255,11 +1264,10 @@ class ObjectSpecificationDescriptor(object): if inst is None: return getObjectSpecification(cls) - provides = getattr(inst, '__provides__', None) - if provides is not None: - return provides - - return implementedBy(cls) + try: + return inst.__provides__ + except AttributeError: + return implementedBy(cls) ############################################################################## |