xm: fix message in OptionError deprecated since Python 2.6

BaseException.message has been deprecated since Python 2.6.  To
prevent DeprecationWarning from popping up over this pre-existing
attribute, use a new property that takes lookup precedence.

Signed-off-by: Wei Kong <weikong.cn@gmail.com>
This commit is contained in:
Keir Fraser committed 2009-12-02 08:47:49 +00:00
1 parent c17b36d5dc
commit 2cdc56dff4
1 file changed
+9
+9
View File
@@ -55,10 +55,19 @@ def wrap(text, width = 70):
return lines
class OptionError(Exception):
def _get_message(self):
return self.__message
def _set_message(self, value):
self.__message = value
message = property(_get_message, _set_message)
"""Denotes an error in option parsing."""
def __init__(self, message, usage = ''):
self.message = message
self.usage = usage
Exception.__init__(self, message)
def __str__(self):
return self.message
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.