Commit ee9ece6a authored by Jérome Perrin's avatar Jérome Perrin

stack/erp5: include missing patches for scripts __code__

This fixes regression when updating instances caused by 4fa33dfc
(erp5: py3: `func_{code,defaults}` was replaced in Python3 by
`__{code,defaults}__`., 2022-04-25)
parent e7f9fa99
Pipeline #21643 failed with stage
in 0 seconds
From 590125ae7c20994055c12be9ba03ae0b43b102ec Mon Sep 17 00:00:00 2001
From: Michael Howitz <mh@gocept.com>
Date: Mon, 23 Oct 2017 16:49:15 +0200
Subject: [PATCH] Force recompilation of scripts.
The compiled code is now stored on `__code__` instead of `func_code`.
Without recompilation the scripts break because `__code__` is `None` which is not expected by ZPublisher/mapply.py
See also zopefoundation/Zope#172.
diff --git a/src/Products/PythonScripts/PythonScript.py b/src/Products/PythonScripts/PythonScript.py
index 29d7db6..28fc2ea 100644
--- a/src/Products/PythonScripts/PythonScript.py
+++ b/src/Products/PythonScripts/PythonScript.py
@@ -58,7 +58,7 @@
del imp
# This should only be incremented to force recompilation.
-Script_magic = 3
+Script_magic = 4
_log_complaint = (
'Some of your Scripts have stale code cached. Since Zope cannot'
' use this code, startup will be slightly slower until these Scripts'
--- Zope2-2.13.30/src/Shared/DC/Scripts/Signature.py 2022-04-25 08:05:09.312966168 +0000
+++ Zope2-2.13.30/src/Shared/DC/Scripts/Signature.py 2022-04-25 08:06:20.120743425 +0000
@@ -35,7 +35,7 @@ def _setFuncSignature(self, defaults=None, varnames=(), argcount=-1):
Make __code__ and __defaults__ already available on scripts
diff --git a/src/App/special_dtml.py b/src/App/special_dtml.py
index 3cefdc3f3..33fc790c2 100644
--- a/src/App/special_dtml.py
+++ b/src/App/special_dtml.py
@@ -87,8 +87,8 @@ from ComputedAttribute import ComputedAttribute
class DTMLFile(Bindings, Explicit, ClassicHTMLFile):
"HTMLFile with bindings and support for __render_with_namespace__"
- func_code = None
- func_defaults = None
+ func_code = __code__ = None
+ func_defaults = __defaults__ = None
_need__name__=1
_Bindings_ns_class = TemplateDict
diff --git a/src/Shared/DC/Scripts/Script.py b/src/Shared/DC/Scripts/Script.py
index 131f06830..28af81507 100644
--- a/src/Shared/DC/Scripts/Script.py
+++ b/src/Shared/DC/Scripts/Script.py
@@ -38,8 +38,8 @@ class Script(SimpleItem, BindingsUI):
security = ClassSecurityInfo()
index_html = None
- func_defaults=()
- func_code=None
+ __defaults__ = func_defaults = ()
+ __code__ = func_code = None
_Bindings_ns_class = TemplateDict
diff --git a/src/Shared/DC/Scripts/Signature.py b/src/Shared/DC/Scripts/Signature.py
index 4f404b9fe..604c4f2e9 100644
--- a/src/Shared/DC/Scripts/Signature.py
+++ b/src/Shared/DC/Scripts/Signature.py
@@ -34,8 +34,8 @@ def _setFuncSignature(self, defaults=None, varnames=(), argcount=-1):
if argcount < 0 and varnames:
argcount = len(varnames)
# Generate a change only if we have to.
if self.func_defaults != defaults:
- if self.func_defaults != defaults:
- self.func_defaults = defaults
+ if self.__defaults__ != defaults:
+ self.func_defaults = self.__defaults__ = defaults
code = FuncCode(varnames, argcount)
if self.func_code != code:
- if self.func_code != code:
- self.func_code = code
+ if self.__code__ != code:
+ self.func_code = self.__code__ = code
......@@ -587,8 +587,11 @@ Acquisition-patches = ${:_profile_base_location_}/../../component/egg-patch/Acqu
Acquisition-patch-options = -p1
python-magic-patches = ${:_profile_base_location_}/../../component/egg-patch/python_magic/magic.patch#de0839bffac17801e39b60873a6c2068
python-magic-patch-options = -p1
Zope2-patches = ${:_profile_base_location_}/../../component/egg-patch/Zope/PythonScript-2.13.patch#124c0d37394dd5020c6fd241ad75cc29
Zope2-patches = ${:_profile_base_location_}/../../component/egg-patch/Zope/PythonScript-2.13.patch#b1be994b0337fe4982b3421a63e82354
Zope2-patch-options = -p1
Zope2-patch-revision = 2
Products.PythonScripts-patches = ${:_profile_base_location_}/../../component/egg-patch/Products.PythonScripts/Force_recompilation_of_scripts.patch#c4afb36b2470af55337912638e21f682
Products.PythonScripts-patch-options = -p1
[eggs-all-scripts]
recipe = zc.recipe.egg
......@@ -624,12 +627,13 @@ depends =
# patched eggs
Acquisition = 2.13.12+SlapOSPatched001
Products.DCWorkflow = 2.2.4+SlapOSPatched001
Products.PythonScripts = 2.13.2+SlapOSPatched001
ocropy = 1.0+SlapOSPatched001
pysvn = 1.9.15+SlapOSPatched001
python-ldap = 2.4.32+SlapOSPatched001
python-magic = 0.4.12+SlapOSPatched001
PyPDF2 = 1.26.0+SlapOSPatched001
Zope2 = 2.13.30+SlapOSPatched001
Zope2 = 2.13.30+SlapOSPatched002
## https://lab.nexedi.com/nexedi/slapos/merge_requests/648
pylint = 1.4.4+SlapOSPatched002
# astroid 1.4.1 breaks testDynamicClassGeneration
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment