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): ...@@ -592,8 +592,9 @@ class BaseTemplateItem(Implicit, Persistent):
# `expression_instance` is included so as to add compatibility for # `expression_instance` is included so as to add compatibility for
# exporting older catalog methods which might have them as their # exporting older catalog methods which might have them as their
# properties or in their attribute dict. # properties or in their attribute dict.
attr_set.update(('func_code', 'func_defaults', '_code', attr_set.update(('func_code', '__code__',
'_lazy_compilation', 'Python_magic', 'func_defaults', '__defaults__',
'_code', '_lazy_compilation', 'Python_magic',
'expression_instance')) 'expression_instance'))
for attr in 'errors', 'warnings', '_proxy_roles': for attr in 'errors', 'warnings', '_proxy_roles':
if not obj.__dict__.get(attr, 1): if not obj.__dict__.get(attr, 1):
......
...@@ -1639,7 +1639,9 @@ def optimize(): ...@@ -1639,7 +1639,9 @@ def optimize():
# Delay the compilations of Python Scripts until they are really executed. # Delay the compilations of Python Scripts until they are really executed.
# Python Scripts are exported without those 2 attributes: # Python Scripts are exported without those 2 attributes:
PythonScript.func_code = lazy_func_prop('func_code', None) 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.func_defaults = lazy_func_prop('func_defaults', None)
PythonScript.__defaults__ = lazy_func_prop('__defaults__', None)
def _compile(self): def _compile(self):
if immediate_compilation: 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