Avoid shadowing Exception 'message' attribute

The Exception class has a 'message' attribute:

  >>> Exception('foo').message
  'foo'

This attribute is deprecated since Python 2.6 and removed in Python 3:

  http://www.python.org/dev/peps/pep-0352/#retracted-ideas

To help porting to Python 3, we should avoid using the .message
attribute at all. However, confusingly, we follow a pattern that results
in the attribute being shadowed by a class attribute:

  >>> class MyException(Exception):
  ...     message = 'Foo %s'
  ...     def __init__(self, bar):
  ...         message = self.message % bar
  ...         super(MyException, self).__init__(message)
  ...
  >>> MyException('bar').message
  'Foo %s'
  >>> str(MyException('bar'))
  'Foo bar'

whereas, we obviously want behaviour like this:

  >>> class MyException(Exception):
  ...     msg_fmt = 'Foo %s'
  ...     def __init__(self, bar):
  ...         message = self.msg_fmt % bar
  ...         super(MyException, self).__init__(message)
  ...
  >>> MyException('bar').message
  'Foo bar'
  >>> str(MyException('bar'))
  'Foo bar'

Avoid this shadowing by using 'msg_fmt' as the name of the class
attribute so it's more obvious where we're actually using the deprecated
.message attribute.

Also add a test which fails without this fix.

Change-Id: I304f31edec20b1293cf6c8de931415590fde6752
Merge "Avoid shadowing Exception 'message' attribute"