[Pythonmac-SIG] Python 2.6 / appscript 0.18.1 DeprecationWarnings fix
Florian Höch
lists+Pythonmac-SIG at hoech.org
Tue Oct 28 14:14:01 CET 2008
Hello list,
I hope this is the correct place to send patches to :)
I noticed that appscript generates some DeprecationWarnings when used
with Python 2.6. It is easily fixed though (I've copied the fixup code
verbatim from Python 2.6's ConfigParser.py):
--- appscript-0.18.1/Lib/aem/send.py.bak Tue Nov 20 19:57:38 2007
+++ appscript-0.18.1/Lib/aem/send.py Sun Oct 26 19:09:37 2008
@@ -132,6 +132,21 @@
raw : AppleEvent | None -- raw reply event, in case
alternate/additional processing of error info is required, or None if
error occurred while outgoing event was being sent
"""
+ def _get_message(self):
+ """Getter for 'message'; needed only to override deprecation in
+ BaseException."""
+ return self.__message
+
+ def _set_message(self, value):
+ """Setter for 'message'; needed only to override deprecation in
+ BaseException."""
+ self.__message = value
+
+ # 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.
+ message = property(_get_message, _set_message)
+
def __init__(self, number, message, raw):
MacOS.Error.__init__(self, *(message and [number, message] or [number]))
self.number, self.message, self.raw = number, message, raw
--- appscript-0.18.1/Lib/aemreceive/handlererror.py.bak Tue Nov 20
19:57:38 2007
+++ appscript-0.18.1/Lib/aemreceive/handlererror.py Sun Oct 26 19:09:17 2008
@@ -11,6 +11,22 @@
class EventHandlerError(Exception):
"""Event-handling callbacks should raise an EventHandlerError
exception to send an error message back to client."""
+
+ def _get_message(self):
+ """Getter for 'message'; needed only to override deprecation in
+ BaseException."""
+ return self.__message
+
+ def _set_message(self, value):
+ """Setter for 'message'; needed only to override deprecation in
+ BaseException."""
+ self.__message = value
+
+ # 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.
+ message = property(_get_message, _set_message)
+
def __init__(self, number, message=None, object=None, coercion=None):
self.number = number
self.message = message
Regards,
Florian Höch
More information about the Pythonmac-SIG
mailing list