##// END OF EJS Templates
tests: drop references to the vendored copy of `zope`...
tests: drop references to the vendored copy of `zope` The `test-check-interfaces.py` test has mostly been a no-op since ef7d85089952. Somehow, checks are still done on mere imports, as these errors were seen when subclassing `Protocol` and adding the `self` argument to the repository interfaces. So just get rid of it. --- /builds/mercurial-ci/tests/test-check-interfaces.py.out +++ /builds/mercurial-ci/tests/test-check-interfaces.py.err @@ -0,0 +1,16 @@ +Traceback (most recent call last): + File "/builds/mercurial-ci/tests/test-check-interfaces.py", line 12, in <module> + from mercurial.interfaces import ( + File "/tmp/hgtests.hl7bqyl0/install/lib/python/mercurial/interfaces/repository.py", line 401, in <module> + @interfaceutil.implementer(ipeerbase) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/tmp/hgtests.hl7bqyl0/install/lib/python/mercurial/thirdparty/zope/interface/declarations.py", line 388, in __call__ + classImplements(ob, *self.interfaces) + File "/tmp/hgtests.hl7bqyl0/install/lib/python/mercurial/thirdparty/zope/interface/declarations.py", line 327, in classImplements + spec.declared += tuple(_normalizeargs(interfaces)) + ^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/tmp/hgtests.hl7bqyl0/install/lib/python/mercurial/thirdparty/zope/interface/declarations.py", line 910, in _normalizeargs + _normalizeargs(v, output) + File "/tmp/hgtests.hl7bqyl0/install/lib/python/mercurial/thirdparty/zope/interface/declarations.py", line 909, in _normalizeargs + for v in sequence: +TypeError: '_ProtocolMeta' object is not iterable ERROR: test-check-interfaces.py output changed Additionally, as will be seen in the next commit, the fact that this code is imported at all has an influence on pytype checking, even when it shouldn't be getting used. Any replacement test will likely be a python file that instantiates things and tries to assign them to variables annotated with a Protocol, and is then checked with pytype. But in the meantime, the explicit subclassing of the Protocol classes will give us some coverage.

File last commit:

r52756:f4733654 default
r53340:0cc50d9a default
Show More
mpatch.py
51 lines | 1.5 KiB | text/x-python | PythonLexer
# mpatch.py - CFFI implementation of mpatch.c
#
# Copyright 2016 Maciej Fijalkowski <fijall@gmail.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import annotations
from typing import List
from ..pure.mpatch import *
from ..pure.mpatch import mpatchError # silence pyflakes
from . import _mpatch # pytype: disable=import-error
ffi = _mpatch.ffi
lib = _mpatch.lib
@ffi.def_extern()
def cffi_get_next_item(arg, pos):
all, bins = ffi.from_handle(arg)
container = ffi.new("struct mpatch_flist*[1]")
to_pass = ffi.new("char[]", bytes(bins[pos]))
all.append(to_pass)
r = lib.mpatch_decode(to_pass, len(to_pass) - 1, container)
if r < 0:
return ffi.NULL
return container[0]
def patches(text: bytes, bins: List[bytes]) -> bytes:
lgt = len(bins)
all = []
if not lgt:
return text
arg = (all, bins)
patch = lib.mpatch_fold(ffi.new_handle(arg), lib.cffi_get_next_item, 0, lgt)
if not patch:
raise mpatchError(b"cannot decode chunk")
outlen = lib.mpatch_calcsize(len(text), patch)
if outlen < 0:
lib.mpatch_lfree(patch)
raise mpatchError(b"inconsistency detected")
buf = ffi.new("char[]", outlen)
if lib.mpatch_apply(buf, text, len(text), patch) < 0:
lib.mpatch_lfree(patch)
raise mpatchError(b"error applying patches")
res = ffi.buffer(buf, outlen)[:]
lib.mpatch_lfree(patch)
return res