From 925385fde6039b20d705465c4aca1436b2d5b14a Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 27 Feb 2019 12:39:09 +0000 Subject: [PATCH] [FIX] base: properly check werkzeug version Werkzeug version was being checked to avoid passing quote=True to werkzeug.utils.escape (as that parameter was changed to `True` *and deprecated* in 0.9). However because DeprecationWarning was made silent by default in Python 3.2 and the way the check is implemented worked for 0.9 it looks like nobody really noticed it's broken in the usual manner of half-assed version checks: works for 0.9.0, doesn't work for 0.12.3 (because lexically 0.12.3 < 0.9.0). Fix by using proper version parsing and comparing the result of that. See also: odoo/odoo#28116 closes odoo/odoo#31553 Signed-off-by: "Xavier Morel (xmo)" --- odoo/addons/base/ir/ir_qweb/qweb.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/ir/ir_qweb/qweb.py b/odoo/addons/base/ir/ir_qweb/qweb.py index 759fdea4054..6a0b8e2e690 100644 --- a/odoo/addons/base/ir/ir_qweb/qweb.py +++ b/odoo/addons/base/ir/ir_qweb/qweb.py @@ -20,6 +20,8 @@ except ImportError: import logging +from odoo.tools import parse_version + unsafe_eval = eval _logger = logging.getLogger(__name__) @@ -146,7 +148,7 @@ class QWebException(Exception): return str(self) # Avoid DeprecationWarning while still remaining compatible with werkzeug pre-0.9 -escape = (lambda text: _escape(text, quote=True)) if getattr(werkzeug, '__version__', '0.0') < '0.9.0' else _escape +escape = (lambda text: _escape(text, quote=True)) if parse_version(getattr(werkzeug, '__version__', '0.0')) < parse_version('0.9.0') else _escape def unicodifier(val): if val is None or val is False: