From 16e44d71d53b29e0f594a2881ec192782e9358d1 2009-10-17 19:50:48 From: Brian Granger Date: 2009-10-17 19:50:48 Subject: [PATCH] Remove usage of deprecated .message attribute of exceptions. This fixes https://bugs.launchpad.net/ipython/+bug/407836. The .message attribute of Exception is being deprecated in Python 2.6. All new code should simply use args[0] for this purpose. There are still a few places that modules in external use this. Hopefully these will be updated soon. --- diff --git a/IPython/core/iplib.py b/IPython/core/iplib.py index ef147fc..a89d6b4 100644 --- a/IPython/core/iplib.py +++ b/IPython/core/iplib.py @@ -1920,7 +1920,7 @@ class InteractiveShell(Component, Magic): # SystemExit exception changed between Python 2.4 and 2.5, so # the checks must be done in a version-dependent way. show = False - if status.message!=0 and not kw['exit_ignore']: + if status.args[0]==0 and not kw['exit_ignore']: show = True if show: self.showtraceback() diff --git a/IPython/frontend/wx/ipythonx.py b/IPython/frontend/wx/ipythonx.py index af7d322..d95d709 100644 --- a/IPython/frontend/wx/ipythonx.py +++ b/IPython/frontend/wx/ipythonx.py @@ -6,11 +6,10 @@ ipython. try: import wx except ImportError, e: - e.message = """%s + e.args[0] = """%s ________________________________________________________________________________ You need wxPython to run this application. -""" % e.message - e.args = (e.message, ) + e.args[1:] +""" % e.args[0] raise e from wx_frontend import WxController diff --git a/IPython/kernel/error.py b/IPython/kernel/error.py index 77db614..23f7cd8 100644 --- a/IPython/kernel/error.py +++ b/IPython/kernel/error.py @@ -127,9 +127,11 @@ class TaskRejectError(KernelError): class CompositeError(KernelError): def __init__(self, message, elist): Exception.__init__(self, *(message, elist)) - self.message = message + # Don't use pack_exception because it will conflict with the .message + # attribute that is being deprecated in 2.6 and beyond. + self.msg = message self.elist = elist - + def _get_engine_str(self, ev): try: ei = ev._ipython_engine_info @@ -137,7 +139,7 @@ class CompositeError(KernelError): return '[Engine Exception]' else: return '[%i:%s]: ' % (ei['engineid'], ei['method']) - + def _get_traceback(self, ev): try: tb = ev._ipython_traceback_text @@ -145,14 +147,14 @@ class CompositeError(KernelError): return 'No traceback available' else: return tb - + def __str__(self): - s = str(self.message) + s = str(self.msg) for et, ev, etb in self.elist: engine_str = self._get_engine_str(ev) s = s + '\n' + engine_str + str(et.__name__) + ': ' + str(ev) return s - + def print_tracebacks(self, excid=None): if excid is None: for (et,ev,etb) in self.elist: