[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] xm: fix message in OptionError deprecated since Python 2.6


  • To: xen-devel@xxxxxxxxxxxxxxxxxxx
  • From: Wei Kong <weikong.cn@xxxxxxxxx>
  • Date: Wed, 2 Dec 2009 12:03:19 +0800
  • Delivery-date: Tue, 01 Dec 2009 20:03:46 -0800
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=HH2T00RFqKkNY3kB8++aiN8LIVy/dtvrrTUTsC6++CD/KEWpT/1v2A+bwSkgBC8d6X Vc3pD7Kgk28fLCuFTE37v5hfMcvqWC4rI2B7IUvmQ+nE0HlbN9JiTDFu9bob6Cx3hxgp Z5MXFbO9BOiWdu0i+Ul+XwpA5O3XGBWQ2Qub4=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

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>

--
--- xen-unstable.hg/tools/python/xen/xm/opts.py 2009-12-02 09:46:51.000000000 +0800
+++ xen-unstable.hg/tools/python/xen/xm/opts.py 2009-12-02 11:56:35.000000000 +0800
@@ -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

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.