From 8ad360ccd3673a77c81e39b08236928fc2fe6c9d Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Mon, 7 Oct 2019 11:44:00 +0000 Subject: [PATCH] [FIX] Log failed queries decoded Starting with Python 3, queries sent by psyocopg2 are stored as `bytes()` objects. Logging those raw makes them appear unformatted, harder to read than in v10 or lower Odoo versions (i.e. `\n` instead of a raw newline character). Decoding the query into unicode makes it easier to read in the logs. closes odoo/odoo#38074 X-original-commit: 329accde2ed6d4dbfdde6d3d99d71e21d15396b7 Signed-off-by: Christophe Simonis --- odoo/sql_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/sql_db.py b/odoo/sql_db.py index 55c420f9d13..922540220b7 100644 --- a/odoo/sql_db.py +++ b/odoo/sql_db.py @@ -240,7 +240,7 @@ class Cursor(object): res = self._obj.execute(query, params) except Exception as e: if self._default_log_exceptions if log_exceptions is None else log_exceptions: - _logger.error("bad query: %s\nERROR: %s", self._obj.query.decode() or query, e) + _logger.error("bad query: %s\nERROR: %s", tools.ustr(self._obj.query or query), e) raise # simple query count is always computed