From 0d8d721d61034a28dad05b63ea66cb0125f4e985 Mon Sep 17 00:00:00 2001 From: jorv <jorv@odoo.com> Date: Thu, 24 Aug 2023 15:45:27 +0200 Subject: [PATCH] [FIX] core: assert `_get_func_code` code argument closes odoo/odoo#33682 Signed-off-by: bve-odoo <bve@odoo.com> --- odoo/tools/_monkeypatches.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/odoo/tools/_monkeypatches.py b/odoo/tools/_monkeypatches.py index f8227a53fc95..8a7329d9f223 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): -- GitLab