Commit 4115e465 authored by Arnaud Fontaine's avatar Arnaud Fontaine

py3: PythonScript: func_{code,defaults} (Python2 only) => __{code,defaults}__ (Python2/Python3).

Use the latter form that works on both. On non-PythonScript code, this is of
course not an issue but Python2 PythonScript does not have a __code__ properties
and requires a patch on Shared.DC.Scripts.Signature (applied by SlapOS recipe)
so that FuncCode() object is set to not only func_code but also __code__.
parent b8b49b2c
......@@ -592,8 +592,9 @@ class BaseTemplateItem(Implicit, Persistent):
# `expression_instance` is included so as to add compatibility for
# exporting older catalog methods which might have them as their
# properties or in their attribute dict.
attr_set.update(('func_code', 'func_defaults', '_code',
'_lazy_compilation', 'Python_magic',
attr_set.update(('func_code', '__code__',
'func_defaults', '__defaults__',
'_code', '_lazy_compilation', 'Python_magic',
'expression_instance'))
for attr in 'errors', 'warnings', '_proxy_roles':
if not obj.__dict__.get(attr, 1):
......
......@@ -1639,7 +1639,9 @@ def optimize():
# Delay the compilations of Python Scripts until they are really executed.
# Python Scripts are exported without those 2 attributes:
PythonScript.func_code = lazy_func_prop('func_code', None)
PythonScript.__code__ = lazy_func_prop('__code__', None)
PythonScript.func_defaults = lazy_func_prop('func_defaults', None)
PythonScript.__defaults__ = lazy_func_prop('__defaults__', None)
def _compile(self):
if immediate_compilation:
......
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