From 986c677bcaa837c5cebaf9d9aa63ea2ff38bf7c2 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 31 Dec 2012 21:14:12 -0500 Subject: [PATCH] swc-installation-test-2.py: Avoid BaseException.message warning Dodge the logic which (at least in Python 2.6.1) raises: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6 We're setting the .message attribute explicitly, so the deprecation warning does not apply to us. The fix was suggested by Brett Cannon: On Sun Jul 8 02:42:18 CEST 2007, Brett Cannon wrote [1]: > You can get around this easily enough with a subclass that uses a > property for message:: > > class gerror(Exception): > def _get_message(self, message): return self._message > def _set_message(self, message): self._message = message > message = property(_get_message, _set_message) [1]: http://mail.python.org/pipermail/python-dev/2007-July/073777.html --- swc-installation-test-2.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/swc-installation-test-2.py b/swc-installation-test-2.py index 0a59778..1f998ba 100755 --- a/swc-installation-test-2.py +++ b/swc-installation-test-2.py @@ -86,7 +86,14 @@ CHECKER = {} class DependencyError (Exception): + def _get_message(self): + return self._message + def _set_message(self, message): + self._message = message + message = property(_get_message, _set_message) + def __init__(self, checker, message): + super(DependencyError, self).__init__(message) self.checker = checker self.message = message -- 2.26.2