add monkey patch for zope.index; constraint zope.publisher to version 5.2.1

This commit is contained in:
Helmut Merz 2024-10-26 19:21:23 +02:00
parent 0f2232648c
commit 22efffa11b
2 changed files with 20 additions and 1 deletions

19
loops/patch.py Normal file
View file

@ -0,0 +1,19 @@
# loops.patch
# monkey patches, activate with: <module module="loops.patch" />
# in some .zcml file, e.g. application.zcml
import zope.index.text.widcode
from zope.index.text.widcode import _prog, _decode, _decoding
def patched_decode(code):
"""_prog pattern is now a string, but after updating from Python2
code is still a bytes array."""
get = _decoding.get
if isinstance(code, bytes):
# byte-wise conversion to str:
code = ''.join(chr(b) for b in code)
return [get(p) or _decode(p) for p in _prog.findall(code)]
zope.index.text.widcode.decode = patched_decode
print("loops.patch: monkey patch for 'zope.index.text.widcode.decode()' installed.")

View file

@ -25,7 +25,7 @@ dependencies = [
"zope.pluggableauth",
"zope.principalannotation",
"zope.principalregistry",
"zope.publisher",
"zope.publisher==5.2.1",
"zope.securitypolicy",
"zope.site",
"zope.thread",