summaryrefslogtreecommitdiff
path: root/HACKING.rst
diff options
context:
space:
mode:
authorJames Carey <jecarey@us.ibm.com>2014-08-15 21:04:46 +0000
committerPádraig Brady <pbrady@redhat.com>2014-08-27 13:55:34 +0100
commit298b0328d2048609a6dce0b919a546c12475a8da (patch)
tree66f5c463b915a00648e7cd6a06ea56b64bde99b9 /HACKING.rst
parentc3ad01b65fd3044cb4240c848afbfbc36222f8f5 (diff)
downloadnova-298b0328d2048609a6dce0b919a546c12475a8da.tar.gz
Remove use of str on exceptions
An exception's message can be a translatable message. If it is, the message can contain unicode characters which will cause str to fail. In cases where the message is explicity needed, the use of str is replaced with the use of six.text_type. When an exception is used as a replacement string in a format string, the logger correctly handles it without the need for str, so it is removed. In addition to the case where a translatable message contains unicode, enabling lazy translation in the oslo.i18n library causes translatable messages to be replaced with an object that does not support str, this causes all calls to str on a translatable message to fail. Thus this patch is also needed to support blueprint: i18n-enablement. This patch includes a hacking check for use of str() on exceptions identified in except statements. Change-Id: Idb426d7f710ea69b835f70d0e883e93e9b9111d2 Partially-Implements: blueprint i18n-enablement
Diffstat (limited to 'HACKING.rst')
-rw-r--r--HACKING.rst1
1 files changed, 1 insertions, 0 deletions
diff --git a/HACKING.rst b/HACKING.rst
index d4cc74b212..3995a9ba08 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -37,6 +37,7 @@ Nova Specific Commandments
- [N322] Method's default argument shouldn't be mutable
- [N323] Ensure that the _() function is explicitly imported to ensure proper translations.
- [N324] Ensure that jsonutils.%(fun)s must be used instead of json.%(fun)s
+- [N325] str() cannot be used on an exception. Remove use or use six.text_type()
Creating Unit Tests
-------------------