From 62a90a603ef3d3c729c4adb95f86a5fb148a98a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 19 Feb 2018 19:09:06 +0100 Subject: [PATCH] Use unicode instead of str for DatabaseIntegrityError The exception message could contain non-ASCII errors for which standard __str__ may fail, but as the database should always be in UTF-8 we may except that unicode will not fail. issue6128 review43971002 --- trytond/model/modelsql.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trytond/model/modelsql.py b/trytond/model/modelsql.py index f1679fe134..7eccd7975b 100644 --- a/trytond/model/modelsql.py +++ b/trytond/model/modelsql.py @@ -295,10 +295,10 @@ class ModelSQL(ModelStorage): cls.raise_user_error('foreign_model_missing', error_args=error_args) for name, _, error in cls._sql_constraints: - if TableHandler.convert_name(name) in str(exception): + if TableHandler.convert_name(name) in unicode(exception): cls.raise_user_error(error) for name, error in cls._sql_error_messages.iteritems(): - if TableHandler.convert_name(name) in str(exception): + if TableHandler.convert_name(name) in unicode(exception): cls.raise_user_error(error) @classmethod