summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* More minor documentation fixups.issue190Jason Madden2020-03-181-12/+13
| | | | Mostly formatting. Some interfaces were being documented as clasess, which doesn't work.
* Make Interface.getTaggedValue follow the __iro__.Jason Madden2020-03-183-28/+203
| | | | | | | | Previously it manually walked up __bases__, meaning the answers could be inconsistent. Fixes #190. Also fixes several minor issues in the documentation, mostly cross-reference related.
* Use C3 (mostly) to compute IRO.issue21Jason Madden2020-03-1515-54/+1001
| | | | | | | | | | | | | | | | | | | | | | | | Fixes #21 The 'mostly' is because interfaces are used in cases that C3 forbids; when there's a conflict, we fallback to the legacy algorithm. It turns out there are few conflicts (13K out of 149K total orderings in Plone). I hoped the fix for #8 might shake out automatically, but it didn't. Optimize the extremely common case of a __bases__ of length one. In the benchmark, 4/5 of the interfaces and related objects have a base of length one. Fix the bad IROs in the bundled ABC interfaces, and implement a way to get warnings or errors. In running plone/buildout.coredev and tracking the RO requests, the stats for equal, not equal, and inconsistent-so-fallback, I got {'ros': 148868, 'eq': 138461, 'ne': 10407, 'inconsistent': 12934} Add the interface module to the Attribute str. This was extremely helpful tracking down the Plone problem; IDate is defined in multiple modules.
* Add additional low-level tests for super() unwrapping.Jason Madden2020-03-101-1/+38
|
* Remove unused str variablesJason Madden2020-03-101-15/+8
| | | | | The DEFINE_STRING macro prevents the linter from seeing them as unused so I temporarily redefined it to find all such variables.
* Make provided/implementedBy and adapter registries respect super().issue11Jason Madden2020-03-095-45/+647
| | | | | | | | | | | | | | | | | | | | | | | | The query functions now start by looking at the next class in the MRO (interfaces directly provided by the underlying object are not found). Adapter registries automatically pick up providedBy change to start finding the correct implementations of adapters, but to make that really useful they needed to change to unpack super() arguments and pass __self__ to the factory. Fixes #11 Unfortunately, this makes PyPy unable to build the C extensions. Additional crash-safety for adapter lookup. Make the C functions get the cache only after resolving the ``required`` into a tuple, in case of side-effects like...clearing the cache. This could lead to the ``cache`` object being deallocated before we used it. Drop the ``tuplefy`` function in favor of a direct call to ``PySequence_Tuple``. It's what the ``tuple`` constructor would do anyway and saves a few steps. Make sure that getting ``providedBy(super())`` and ``implementedBy(super())`` have no side effects.
* Cleanups per review.issue138Jason Madden2020-02-175-41/+34
|
* Update documentation and clarify the relationship of the older mapping and ↵Jason Madden2020-02-177-49/+158
| | | | sequence interfaces.
* Do not test _WindowsConsoleIOJason Madden2020-02-171-1/+1
|
* Find more concrete classes that are registered.Jason Madden2020-02-175-15/+41
|
* Add interfaces for builtins and the io ABCs.Jason Madden2020-02-179-64/+439
|
* Add numbers ABC interfaces.Jason Madden2020-02-175-39/+199
|
* Add collections.IByteString and refactor to avoid one-to-one assumption ↵Jason Madden2020-02-173-45/+161
| | | | | | about ABCs and builtins. bytearray turns out to violate that.
* Add z.i.common.collections to parallel the collections.abc classes.Jason Madden2020-02-173-2/+482
| | | | | | | | Register implemented standard library types on import. Derive the interface methods and documentation from the ABC automatically. I hope to use this for numbers too. Part of #138
* Merge pull request #177 from zopefoundation/fix-signatureJens W. Klein2020-02-162-5/+5
|\ | | | | Fix repr of "Attribute" to look like before
| * Fix repr of "Attribute" to look like beforeJens W. Klein2020-02-162-5/+5
| | | | | | | | and as usual in Python.
* | Add test case for #6.issue6Jason Madden2020-02-141-1/+50
|/ | | | It seems to be working now, so this fixes #6
* Simplify the string formatting rules for the Invalid exceptions.Jason Madden2020-02-103-77/+221
| | | | | | As per review. Also include the actual failing implementation object in the BrokenMethodImplementation to make it easier to track down what's going on when inheritance is involved.
* Make verifyObject/Class collect and raise all errors instead of only the first.issue171Jason Madden2020-02-084-85/+247
| | | | Fixes #171.
* Add warning to change note about string changes breaking doctests.Jason Madden2020-02-082-7/+31
| | | | Also tweak documentation to DRY for verifyObject/verifyClass.
* Also document the not-a-method case.issue170Jason Madden2020-02-071-1/+1
|
* Make verification errors more readable and useful.Jason Madden2020-02-075-47/+180
| | | | | | | | | | | | | | Eliminate the trailing newlines and blank spaces (the code called them "a stupid artifact"). Include the name of the defining interface (so the user can easily look up any requirements on the attribute) and, for methods, the expected signature (no more guessing about how many arguments are required!). This is implemented by giving Attribute and Method useful reprs and strs. Previously, they just had the defaults. Fixes #170
* Fix verification for methods of builtin types with pseudo-default arguments ↵issue118Jason Madden2020-02-066-46/+162
| | | | | | | | | on Pypy On PyPy2, they are ignored (like on CPython), but on PyPy3 they can actually be validated. Fixes #118
* Add __all__ to all modules.issue153Jason Madden2020-02-0510-39/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #153 The items that went in each ``__all__`` are based on what is documented: $ rg --no-filename 'import' docs/ -trst | tr -s "[:blank:]" | sort | uniq | grep zope >>> from pprint import pprint >>> from zope.interface import * >>> from zope.interface import Interface >>> from zope.interface import Interface, Attribute, implementer >>> from zope.interface import alsoProvides >>> from zope.interface import classImplements >>> from zope.interface import classImplementsOnly >>> from zope.interface import directlyProvidedBy >>> from zope.interface import directlyProvides >>> from zope.interface import implementedBy >>> from zope.interface import implementer >>> from zope.interface import implementer_only >>> from zope.interface import noLongerProvides >>> from zope.interface import providedBy >>> from zope.interface import provider >>> from zope.interface.adapter import AdapterRegistry >>> from zope.interface.declarations import Declaration >>> from zope.interface.declarations import InstanceDeclarations >>> from zope.interface.declarations import ProvidesClass >>> from zope.interface.declarations import named >>> from zope.interface.exceptions import BrokenImplementation >>> from zope.interface.exceptions import Invalid >>> from zope.interface.interface import Specification >>> from zope.interface.interface import adapter_hooks >>> from zope.interface.verify import verifyObject >>> import gc >>> import zope.interface And also some personal judgement about what the public API is that I'm more than happy to have reviewed.
* better namingJens W. Klein2020-02-041-9/+9
|
* iPerformace optimization in _lookup _lookupAll _subscriptionslookup-performanceJens W. Klein2020-02-041-6/+13
|
* The _empty singleton has no-op subscribe/unsubscribe methods.issue162Jason Madden2020-01-283-9/+43
| | | | | | | | Turns out they can be called in some very strange error cases. See #162 and #163 for details. This should fix #162 (at least the provided test case, five.intid, passes now). It also does enough work on #163 that (a) the test can be written and run in pure-python mode, which was needed to debug it and (b) five.intid runs in pure-python mode (well, with a bunch of other small hacks to Acquisition, ExtensionClass, DocumentTemplate and AccessControl), but I won't claim that it fully fixes #163. For one thing, there are no specific tests. For another, I see more such differences.
* apply suggestion by @jmadden to enhance commentJens W. Klein2020-01-281-2/+2
|
* Remove unneeded overwrite and call to anyway inherited __hash__ methodhash_performance_2Jens W. Klein2020-01-281-3/+0
|
* Add comment detailing why __bases__ can be set per review.issue158Jason Madden2020-01-271-1/+7
|
* Make the singleton _empty immutable.Jason Madden2020-01-272-3/+101
| | | | Fixes #158
* Remove support for hashing uninitialized interfaces.issue157Jason Madden2020-01-272-17/+4
| | | | Fixes #157
* Whitespace.Jason Madden2020-01-271-1/+1
|
* Avoid allocating space for tagged values unless they're used. This saves ↵Jason Madden2020-01-271-3/+9
| | | | another few percent.
* Specifications with no dependents are common (4700 out of 7000 in this ↵Jason Madden2020-01-272-13/+29
| | | | | | example), so avoid allocating a WeakKeyDictionary until needed. This saves another 2% or so.
* Move Declaration, Specification and ClassProvides to __slots__.Jason Madden2020-01-275-37/+93
| | | | In a test of 6000 modules that load 2245 InterfaceClass objects and produce 2233 ClassProvides instances, this saves about 1% total memory usage in Python 2.7.
* cache on volatile attribute in case class is persisted in ZODBhash_performanceJens W. Klein2020-01-251-3/+3
|
* Improve InterfaceClass __hash__ performanceJens W. Klein2020-01-241-5/+9
|
* Use tp_members in SpecificationBase and ClassProvidesBase.Jason Madden2020-01-234-232/+275
| | | | | | | | | | | | Instead of storing 1 and 2 attributes, respectively, in __dict__. This lets us eliminate inst_attr and its use of an undocumented API. It also helps reign in the size of these objects. Before, on CPython 8, a ClassProvides object that subclasses both SpecificationBase and ClassProvidesBase required 408 bytes: 48 for the object, 360 for the dict. Now it requires 72 + 232 = 304. With a bit of work on defining __slots__ in Python, that can be brought much lower still, I think. zope.security tests pass with this installed.
* Bump version as suggested in review.no-pure-python-buildJason Madden2020-01-221-0/+1
| | | | Also add a line of missing whitespace.
* Tweaks for coverage reporting.Jason Madden2020-01-211-2/+2
| | | | And tox. It wasn't properly working to report coverage before.
* Test PURE_PYTHON at runtime.Jason Madden2020-01-219-260/+350
| | | | | | | Turns out that the C extensions build and work fine with PyPy, but don't use them by default. Let them be forced, though. Tests needed some refactoring to account for the various permutations.
* Remove unused test files.Jason Madden2020-01-213-67/+0
|
* key order doesn't mattermauro2019-10-091-1/+1
|
* fix 'dict_keys' object has no attribute 'extend'mauro2019-10-091-3/+5
|
* taggedvalue inheritancemauro2019-10-092-2/+36
|
* Fix coverage.issue126Jason Madden2018-10-231-2/+2
|
* Fix 'verifyObject' for class objects with staticmethods on Python 3.Jason Madden2018-10-232-1/+25
| | | | Fixes #126
* Reorganize the 'declarations' document by functional group.Jason Madden2018-07-192-42/+42
| | | | Add cross references and some formatting fixes.
* Formatting and cross refs for the 'Interface Specification' docJason Madden2018-07-192-26/+27
|