summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Drop support for Python 2.7, 3.5, 3.6. (#266)Michael Howitz2022-12-2839-1744/+674
| | | Co-authored-by: Jens Vagelpohl <jens@plyp.com>
* Fix test deprecation warning on Python 3.11Colin Watson2022-12-101-4/+7
| | | | | | | | | | | Python 3.11 warns: DeprecationWarning: It is deprecated to return a value that is not None from a test case (<bound method Test_c3_ro.test_complex_diamond of <zope.interface.tests.test_ro.Test_c3_ro testMethod=test_complex_diamond>>) Rearrange slightly to avoid this.
* Update to the latest c-code templateMarius Gedminas2022-09-091-0/+29
| | | | | | | | | | | Add a regression test for CFLAGS not having -Ofast, which is known to break things. See https://github.com/zopefoundation/meta/pull/155 for reference. This reverts commit dc2e4b9841185889bdf8b77ee5c28f5b7295578a, which itself was reverting commit 22a761cc9e6fcfa840582d55a15abda31a9dd2e1, which was accidentally pushed to git master and is otherwise identical to this commit.
* Revert "Update to the latest c-code template"Marius Gedminas2022-09-091-29/+0
| | | | | | This reverts commit 22a761cc9e6fcfa840582d55a15abda31a9dd2e1. This was not supposed to have been pushed directly to master :/
* Update to the latest c-code templateMarius Gedminas2022-09-091-0/+29
| | | | | | Add a regression test for CFLAGS not having -Ofast, which is known to break things. See https://github.com/zopefoundation/meta/pull/155 for reference.
* Fix tests for PyPy3.Michael Howitz2022-03-291-1/+2
| | | | | | | | | | | | | | | On PyPy3 the following `registered_classes` for `IMutableMapping` are found: ``` {<class 'dict'>, <class 'pkg_resources._vendor.pyparsing.ParseResults'>, <class 'setuptools._vendor.pyparsing.ParseResults'>, <class 'collections.UserDict'>} ``` So collecting the tests fails because of a duplicate name which is prevented by this commit.
* Fix typos (#251)Kian-Meng Ang2022-01-257-10/+10
| | | Co-authored-by: Michael Howitz <mh@gocept.com>
* Add support for Python 3.10 (#250)Michael Howitz2022-01-242-10/+33
| | | | | * Fix tests on Python 3.10. * "Fix" a test broken just on windows + allow to use posargs for tox test runs. * Checking array.array non-strictly did not help on Windows. – So ignore it completely.
* Add some more entries to zope.interface.interfaces.__all__Colin Watson2021-09-021-0/+5
| | | | | | | | | `ComponentLookupError`, `Invalid`, `Registered`, and `Unregistered` are all documented (https://zopeinterface.readthedocs.io/en/latest/api/components.html), so it seems odd not to list them in `__all__`. `ObjectEvent` isn't documented there, but it seems reasonable to export it as a base class for similar events.
* Configure with meta/config. (#243)Michael Howitz2021-06-023-47/+47
| | | | * Add support for Python 3.9. * Improve coverage.
* Merge pull request #240 from zopefoundation/issue239Jason Madden2021-04-153-10/+71
|\ | | | | Make C's __providedBy__ stop ignoring all errors and catch only AttributeError
| * Finish sentence in docstring. [skip ci]Jason Madden2021-04-151-1/+2
| |
| * Make C's __providedBy__ stop ignoring all errors and catch only AttributeError.issue239Jason Madden2021-04-133-10/+70
| | | | | | | | | | | | | | Fixes #239 There was a similar bug in the Python side where it would ignore a __provides__ of None, unlike the C implementation. I documented this in the code but not the CHANGES.rst because I can't imagine anyone relying on that.
* | Make Declaration.__add__ try harder to produce consistent resolution orders.issue193Jason Madden2021-04-012-10/+75
|/ | | | | | By moving things from the RHS to the front of the list if they already extend something from the LHS. Fixes #193
* Update repr() and str() of some common objects.issue236Jason Madden2021-03-255-76/+413
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only InterfaceClass got a str, so it now has a distinction. Other objects only got updated reprs. Note: This may potentially break some doctests. In many cases, the ``repr()`` is now something that can be evaluated to produce an equal object. For example, what was previously printed as ``<implementedBy builtins.list>`` is now shown as ``classImplements(list, IMutableSequence, IIterable)``. Fixes #236 Here's a before with ZOPE_INTERFACE_LOG_CHANGED_IRO=1 in BTrees: ``` Object <implementedBy builtins.list> has different legacy and C3 MROs: Legacy RO (len=11) C3 RO (len=11; inconsistent=no) ================================================================================================================================================== <implementedBy builtins.list> <implementedBy builtins.list> <ABCInterfaceClass zope.interface.common.collections.IMutableSequence> <ABCInterfaceClass zope.interface.common.collections.IMutableSequence> <ABCInterfaceClass zope.interface.common.collections.ISequence> <ABCInterfaceClass zope.interface.common.collections.ISequence> <ABCInterfaceClass zope.interface.common.collections.IReversible> <ABCInterfaceClass zope.interface.common.collections.IReversible> <ABCInterfaceClass zope.interface.common.collections.ICollection> <ABCInterfaceClass zope.interface.common.collections.ICollection> <ABCInterfaceClass zope.interface.common.collections.ISized> <ABCInterfaceClass zope.interface.common.collections.ISized> + <ABCInterfaceClass zope.interface.common.collections.IIterable> <ABCInterfaceClass zope.interface.common.collections.IContainer> <ABCInterfaceClass zope.interface.common.collections.IContainer> - <ABCInterfaceClass zope.interface.common.collections.IIterable> <ABCInterfaceClass zope.interface.common.ABCInterface> <ABCInterfaceClass zope.interface.common.ABCInterface> + <implementedBy builtins.object> <InterfaceClass zope.interface.Interface> <InterfaceClass zope.interface.Interface> - <implementedBy builtins.object> Object <ABCInterfaceClass zope.interface.common.mapping.IFullMapping> has different legacy and C3 MROs: Legacy RO (len=18) C3 RO (len=18; inconsistent=no) ================================================================================================================================================ <ABCInterfaceClass zope.interface.common.mapping.IFullMapping> <ABCInterfaceClass zope.interface.common.mapping.IFullMapping> <ABCInterfaceClass zope.interface.common.collections.IMutableMapping> <ABCInterfaceClass zope.interface.common.collections.IMutableMapping> <ABCInterfaceClass zope.interface.common.collections.IMapping> <ABCInterfaceClass zope.interface.common.collections.IMapping> <ABCInterfaceClass zope.interface.common.collections.ICollection> <ABCInterfaceClass zope.interface.common.collections.ICollection> - <ABCInterfaceClass zope.interface.common.collections.IIterable> <InterfaceClass zope.interface.common.mapping.IExtendedReadMapping> <InterfaceClass zope.interface.common.mapping.IExtendedReadMapping> <InterfaceClass zope.interface.common.mapping.IIterableMapping> <InterfaceClass zope.interface.common.mapping.IIterableMapping> <InterfaceClass zope.interface.common.mapping.IExtendedWriteMapping> <InterfaceClass zope.interface.common.mapping.IExtendedWriteMapping> <InterfaceClass zope.interface.common.mapping.IClonableMapping> <InterfaceClass zope.interface.common.mapping.IClonableMapping> <InterfaceClass zope.interface.common.mapping.IMapping> <InterfaceClass zope.interface.common.mapping.IMapping> <InterfaceClass zope.interface.common.mapping.IWriteMapping> <InterfaceClass zope.interface.common.mapping.IWriteMapping> <InterfaceClass zope.interface.common.mapping.IEnumerableMapping> <InterfaceClass zope.interface.common.mapping.IEnumerableMapping> <ABCInterfaceClass zope.interface.common.collections.ISized> <ABCInterfaceClass zope.interface.common.collections.ISized> + <ABCInterfaceClass zope.interface.common.collections.IIterable> <InterfaceClass zope.interface.common.mapping.IReadMapping> <InterfaceClass zope.interface.common.mapping.IReadMapping> <ABCInterfaceClass zope.interface.common.collections.IContainer> <ABCInterfaceClass zope.interface.common.collections.IContainer> <ABCInterfaceClass zope.interface.common.ABCInterface> <ABCInterfaceClass zope.interface.common.ABCInterface> <InterfaceClass zope.interface.common.mapping.IItemMapping> <InterfaceClass zope.interface.common.mapping.IItemMapping> <InterfaceClass zope.interface.Interface> <InterfaceClass zope.interface.Interface> Object <InterfaceClass BTrees.Interfaces.ISet> has different legacy and C3 MROs: Legacy RO (len=7) C3 RO (len=7; inconsistent=no) ==================================================================================================== <InterfaceClass BTrees.Interfaces.ISet> <InterfaceClass BTrees.Interfaces.ISet> <InterfaceClass BTrees.Interfaces.IKeySequence> <InterfaceClass BTrees.Interfaces.IKeySequence> - <InterfaceClass BTrees.Interfaces.ISized> <InterfaceClass BTrees.Interfaces.ISetMutable> <InterfaceClass BTrees.Interfaces.ISetMutable> <InterfaceClass BTrees.Interfaces.IKeyed> <InterfaceClass BTrees.Interfaces.IKeyed> <InterfaceClass BTrees.Interfaces.ICollection> <InterfaceClass BTrees.Interfaces.ICollection> + <InterfaceClass BTrees.Interfaces.ISized> <InterfaceClass zope.interface.Interface> <InterfaceClass zope.interface.Interface> ``` And here's after: ``` Object classImplements(list, IMutableSequence, IIterable) has different legacy and C3 MROs: Legacy RO (len=11) C3 RO (len=11; inconsistent=no) ========================================================================================================== classImplements(list, IMutableSequence, IIterable) classImplements(list, IMutableSequence, IIterable) zope.interface.common.collections.IMutableSequence zope.interface.common.collections.IMutableSequence zope.interface.common.collections.ISequence zope.interface.common.collections.ISequence zope.interface.common.collections.IReversible zope.interface.common.collections.IReversible zope.interface.common.collections.ICollection zope.interface.common.collections.ICollection zope.interface.common.collections.ISized zope.interface.common.collections.ISized + zope.interface.common.collections.IIterable zope.interface.common.collections.IContainer zope.interface.common.collections.IContainer - zope.interface.common.collections.IIterable zope.interface.common.ABCInterface zope.interface.common.ABCInterface + classImplements(object) zope.interface.Interface zope.interface.Interface - classImplements(object) Object <ABCInterfaceClass zope.interface.common.mapping.IFullMapping> has different legacy and C3 MROs: Legacy RO (len=18) C3 RO (len=18; inconsistent=no) ============================================================================================================ zope.interface.common.mapping.IFullMapping zope.interface.common.mapping.IFullMapping zope.interface.common.collections.IMutableMapping zope.interface.common.collections.IMutableMapping zope.interface.common.collections.IMapping zope.interface.common.collections.IMapping zope.interface.common.collections.ICollection zope.interface.common.collections.ICollection - zope.interface.common.collections.IIterable zope.interface.common.mapping.IExtendedReadMapping zope.interface.common.mapping.IExtendedReadMapping zope.interface.common.mapping.IIterableMapping zope.interface.common.mapping.IIterableMapping zope.interface.common.mapping.IExtendedWriteMapping zope.interface.common.mapping.IExtendedWriteMapping zope.interface.common.mapping.IClonableMapping zope.interface.common.mapping.IClonableMapping zope.interface.common.mapping.IMapping zope.interface.common.mapping.IMapping zope.interface.common.mapping.IWriteMapping zope.interface.common.mapping.IWriteMapping zope.interface.common.mapping.IEnumerableMapping zope.interface.common.mapping.IEnumerableMapping zope.interface.common.collections.ISized zope.interface.common.collections.ISized + zope.interface.common.collections.IIterable zope.interface.common.mapping.IReadMapping zope.interface.common.mapping.IReadMapping zope.interface.common.collections.IContainer zope.interface.common.collections.IContainer zope.interface.common.ABCInterface zope.interface.common.ABCInterface zope.interface.common.mapping.IItemMapping zope.interface.common.mapping.IItemMapping zope.interface.Interface zope.interface.Interface Object <InterfaceClass BTrees.Interfaces.ISet> has different legacy and C3 MROs: Legacy RO (len=7) C3 RO (len=7; inconsistent=no) ================================================================== BTrees.Interfaces.ISet BTrees.Interfaces.ISet BTrees.Interfaces.IKeySequence BTrees.Interfaces.IKeySequence - BTrees.Interfaces.ISized BTrees.Interfaces.ISetMutable BTrees.Interfaces.ISetMutable BTrees.Interfaces.IKeyed BTrees.Interfaces.IKeyed BTrees.Interfaces.ICollection BTrees.Interfaces.ICollection + BTrees.Interfaces.ISized zope.interface.Interface zope.interface.Interface ```
* Improve the tests for ProvidesClass.__repr__.Jason Madden2021-03-181-5/+11
|
* Update documentation and Provides repr for better debugging.Jason Madden2021-03-183-3/+33
| | | | | | Fixes #229. Replaces #232
* Merge pull request #235 from zopefoundation/issue207Jason Madden2021-03-183-6/+107
|\ | | | | Make Provides and ClassProvides ignore redundant interfaces like @implementer
| * Make Provides and ClassProvides ignore redundant interfaces like @implementerissue207Jason Madden2021-03-173-6/+107
| | | | | | | | cf #207
* | Merge pull request #233 from zopefoundation/docs-updateJason Madden2021-03-174-5/+16
|\ \ | |/ |/| Update the Adaptation docs to be more concrete.
| * Update the Adaptation docs to be more concrete.docs-updateJason Madden2021-03-174-5/+16
| | | | | | | | | | | | This should help provide better motivating use cases. Examples inspired by https://glyph.twistedmatrix.com/2021/03/interfaces-and-protocols.html Also some minor typo fixes and updates to comments.
* | Tweak wrapping in subscribed() docstring.issue230Jason Madden2021-03-161-2/+2
| |
* | Add missing quote in docstring in src/zope/interface/registry.pyJason Madden2021-03-161-1/+1
| | | | | | Co-authored-by: Marius Gedminas <marius@gedmin.as>
* | Share code between registered and subscribed.Jason Madden2021-03-151-20/+20
| |
* | Add IAdapterRegistry.subscribed and ↵Jason Madden2021-03-155-4/+242
|/ | | | | | Components.rebuildUtilityRegistryFromLocalCache Fixes #230
* Expand on some comments. [skip ci]Jason Madden2021-03-151-1/+14
|
* Move itertools import to module scope.issue224Jason Madden2021-03-151-30/+73
| | | | Also tweak docs.
* Let subclasses of BaseAdapterRegistry customize the data structures.Jason Madden2021-03-033-25/+844
| | | | | | | | | | | | Add extensive tests for this. Fixes #224. Also adds test for, and fixes #227 Add BAR.rebuild() to fix the refcount issue, and to change datatypes. It works by using the new methods allRegistrations() and allSubscriptions() to re-create the data in new data structures. This makes fresh calls to subscribe() and register(). I went this way instead of trying to manually walk the data structures and create them because the logic in those methods is fully tested.
* Merge branch 'master' of github.com:zopefoundation/zope.interface into masterJan-Jaap Driessen2020-10-012-0/+31
|\
| * C optimizations: Spec_clear and Spec_traverse need to include Spec->_basesJason Madden2020-09-282-0/+31
| | | | | | | | | | | | Previously they did not, leading to a reference leak of a tuple. Fixes #216
* | Use queryDirectTaggedValue to find invariants removes the need to keep track ↵Jan-Jaap Driessen2020-10-011-21/+13
| | | | | | | | of invariants we have already seen.
* | Use an internal method for validating invariants, so we don't taint the ↵Jan-Jaap Driessen2020-09-281-5/+6
| | | | | | | | public interface/signature.
* | When an invariant is defined in an interface, it's found byJan-Jaap Driessen2020-09-252-2/+21
|/ | | | | `validateInvariants` in all interfaces inheriting from that interface. Make sure to call each invariant only once when validating invariants.
* Fix interface definitions of IAdapterRegistry.subscribe, subscribers and ↵Jason Madden2020-04-233-78/+114
| | | | | | | | subscriptions. They were defined to accept a name argument, but the actual implementation doesn't. Add tests for this. Fixes #208. Also in test_adapter.py modernize idioms from assertTrue(x in y) and assertTrue(x is y) to assertIn and assertIs.
* Merge pull request #203 from zopefoundation/issue199Jason Madden2020-04-083-147/+246
|\ | | | | Make @implementer and classImplements not add redundant interfaces
| * Fix implementerOnly when duplicating something inherited from the parent.issue199Jason Madden2020-04-072-79/+89
| | | | | | | | | | | | Seen in plone.app.testing as a problem in Products.GenericSetup. Added tests for that.
| * Special case the base Interface in @implementer/classImplements to skip the ↵Jason Madden2020-04-073-10/+43
| | | | | | | | redundancy detection for the sake of plone.app.caching.
| * Make @implementer and classImplements not re-declare redundant interfaces.Jason Madden2020-04-072-90/+146
| | | | | | | | classImplementsOnly and @implementer_only can still be used to do that.
* | Merge pull request #205 from zopefoundation/issue204Jason Madden2020-04-072-6/+39
|\ \ | | | | | | The ImmutableDeclaration also has immutable _v_attrs.
| * | The ImmutableDeclaration also has immutable _v_attrs.issue204Jason Madden2020-04-072-6/+39
| |/ | | | | | | Fixes #204
* | Minor cleanup of #202.issue3_minor_cleanupJason Madden2020-04-071-2/+11
|/ | | | See https://github.com/zopefoundation/zope.interface/pull/202#pullrequestreview-389126705
* Feedback from review: whitespace, doc clarification, and a unit test showing ↵Jason Madden2020-04-074-18/+58
| | | | the precedence of __conform__ vs __adapt__.
* Let interface 'subclasses' override __adapt__.issue3Jason Madden2020-04-068-58/+312
| | | | | | | | | | | | | | | | | | | | Cooperate with InterfaceClass to ensure there is no performance penalty for this. Fixes #3 +-------------------------------------------------------------+----------------+------------------------------+------------------------------+ | Benchmark | bench_master38 | bench_issue3 | bench_issue3_opt | +=============================================================+================+==============================+==============================+ | call interface (provides; deep) | 369 ns | 454 ns: 1.23x slower (+23%) | not significant | +-------------------------------------------------------------+----------------+------------------------------+------------------------------+ | call interface (provides; wide) | 373 ns | 457 ns: 1.22x slower (+22%) | 365 ns: 1.02x faster (-2%) | +-------------------------------------------------------------+----------------+------------------------------+------------------------------+ | call interface (no alternate, no conform, not provided) | 671 ns | 760 ns: 1.13x slower (+13%) | 636 ns: 1.06x faster (-5%) | +-------------------------------------------------------------+----------------+------------------------------+------------------------------+ | call interface (alternate, no conform, not provided) | 395 ns | 494 ns: 1.25x slower (+25%) | not significant | +-------------------------------------------------------------+----------------+------------------------------+------------------------------+ | call interface (no alternate, valid conform, not provided) | 250 ns | not significant | 227 ns: 1.10x faster (-9%) | +-------------------------------------------------------------+----------------+------------------------------+------------------------------+ | call interface (alternate, invalid conform, not provided) | 348 ns | 424 ns: 1.22x slower (+22%) | not significant | +-------------------------------------------------------------+----------------+------------------------------+------------------------------+
* Add documentation for taggedValue and invariant.Jason Madden2020-04-061-0/+51
|
* Add more cross refs to documentation and fix a couple sphinx warnings about ↵Jason Madden2020-04-061-42/+98
| | | | duplicates in the index.
* MS VS stuck on c89 strikes again.Jason Madden2020-04-021-1/+1
|
* Remove the bare except: statements.Jason Madden2020-04-027-193/+384
| | | | | | | | Only catch AttributeError instead of everything. Fixes #200 Note that this does break a doctest in five.intid (it's expecting a TypeError but it now gets Acquisition's RuntimeError).
* Ensure that objects that implement no interfaces still have Interface in ↵Jason Madden2020-03-303-12/+54
| | | | | | their iro and sro. Fixes #197.
* Make the RO for InterfaceClass consistent and fix handling of the STRICT_IRO ↵issue192-issue194Jason Madden2020-03-206-25/+78
| | | | | | | | env variable. Fixes #192 and fixes #194. Also fix the IRO for OrderedDict on CPython 2
* Another comment update, referencing #163Jason Madden2020-03-191-2/+7
|