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
This commit is contained in:
1 parent
8a7953bb8f
commit
62a90a603e
1 file changed
+2
-2
@@ -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
|
||||
|
||||
Reference in new issue
Block a user