From eca7725d63e9c22b6b9062774c5fe640c211d141 Mon Sep 17 00:00:00 2001
From: Arnaud Fontaine <arnaud.fontaine@nexedi.com>
Date: Mon, 25 Apr 2022 15:13:53 +0200
Subject: [PATCH] erp5: py3: `func_{code,defaults}` was replaced in Python3 by
 `__{code,defaults}__`.

Python2 already provides __code__ and __defaults__ so this just does the same on
PythonScript.
---
 component/egg-patch/Zope/PythonScript-2.13.patch | 12 ++++++++++++
 stack/erp5/buildout.cfg                          |  3 +++
 2 files changed, 15 insertions(+)
 create mode 100644 component/egg-patch/Zope/PythonScript-2.13.patch

diff --git a/component/egg-patch/Zope/PythonScript-2.13.patch b/component/egg-patch/Zope/PythonScript-2.13.patch
new file mode 100644
index 000000000..3d6b37127
--- /dev/null
+++ b/component/egg-patch/Zope/PythonScript-2.13.patch
@@ -0,0 +1,12 @@
+--- 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):
+         argcount = len(varnames)
+     # Generate a change only if we have to.
+     if self.func_defaults != defaults:
+-        self.func_defaults = defaults
++        self.func_defaults = self.__defaults__ = defaults
+     code = FuncCode(varnames, argcount)
+     if self.func_code != code:
+-        self.func_code = code
++        self.func_code = self.__code__ = code
diff --git a/stack/erp5/buildout.cfg b/stack/erp5/buildout.cfg
index b381f5c75..b468e0e28 100644
--- a/stack/erp5/buildout.cfg
+++ b/stack/erp5/buildout.cfg
@@ -588,6 +588,8 @@ 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-patch-options = -p1
 
 [eggs-all-scripts]
 recipe = zc.recipe.egg
@@ -628,6 +630,7 @@ 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
 ## https://lab.nexedi.com/nexedi/slapos/merge_requests/648
 pylint = 1.4.4
 
-- 
2.30.9