diff --git a/odoo/tools/_monkeypatches.py b/odoo/tools/_monkeypatches.py index f8227a53fc9539647627a2727a1f399c4c4bd36b..8a7329d9f2235c2bf71ef671a481c911c1b2e96e 100644 --- a/odoo/tools/_monkeypatches.py +++ b/odoo/tools/_monkeypatches.py @@ -2,10 +2,12 @@ import ast import os import logging from shutil import copyfileobj +from types import CodeType _logger = logging.getLogger(__name__) from werkzeug.datastructures import FileStorage +from werkzeug.routing import Rule from werkzeug.wrappers import Request, Response from .json import scriptsafe @@ -33,6 +35,14 @@ FileStorage.save = lambda self, dst, buffer_size=1<<20: copyfileobj(self.stream, Request.json_module = Response.json_module = scriptsafe +get_func_code = getattr(Rule, '_get_func_code', None) +if get_func_code: + @staticmethod + def _get_func_code(code, name): + assert isinstance(code, CodeType) + return get_func_code(code, name) + Rule._get_func_code = _get_func_code + orig_literal_eval = ast.literal_eval def literal_eval(expr):