From d1da173017216a4506d93203a3c1c2fb6bba96b8 Mon Sep 17 00:00:00 2001 From: Liang Chen Date: Sun, 14 Apr 2013 22:44:12 +0800 Subject: Enable unicode error message Keystone exceptions could only take byte string message as the message arguments to construct exception instances because of the way its super class StandardError implements __unicode__. This patch can also make sure it would not unintentionally remove line breaks and indentation in a explicitly given message argument. Fixs bug #1168879 Change-Id: I7916efc87845cfc4dba705e9474125b275affc13 --- keystone/exception.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'keystone') diff --git a/keystone/exception.py b/keystone/exception.py index eaacfcf0..21844300 100644 --- a/keystone/exception.py +++ b/keystone/exception.py @@ -56,14 +56,10 @@ class Error(StandardError): :raises: KeyError given insufficient kwargs """ - return message or self.__doc__ % kwargs - - def __str__(self): - """Cleans up line breaks and indentation from doc strings.""" - string = super(Error, self).__str__() - string = re.sub('[ \n]+', ' ', string) - string = string.strip() - return string + if not message: + message = re.sub('[ \n]+', ' ', self.__doc__ % kwargs) + message = message.strip() + return message class ValidationError(Error): -- cgit