[IPython-dev] parallel: BaseException.message has been deprecated

Ondrej Certik ondrej at certik.cz
Wed Mar 18 23:40:42 EDT 2009


> but I only got:
>
> Traceback (most recent call last):
>  File "t.py", line 30, in <module>
>    v.raise_exception()
>  File "/home/ondrej/lib/lib/python/IPython/kernel/error.py", line
> 157, in raise_exception
>    raise et, ev, etb
> TypeError: exceptions must be classes or instances, not str

So this problem is because python2.6 doesn't allow string exceptions.
For some reason, et, ev and etb are just strings. So I am now using
this patch:

=== modified file 'IPython/kernel/error.py'
--- IPython/kernel/error.py	2008-06-06 19:41:55 +0000
+++ IPython/kernel/error.py	2009-03-19 03:23:44 +0000
@@ -107,7 +107,7 @@
 class CompositeError(KernelError):
     def __init__(self, message, elist):
         Exception.__init__(self, *(message, elist))
-        self.message = message
+        self.msg = message
         self.elist = elist

     def _get_engine_str(self, ev):
@@ -127,10 +127,10 @@
             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)
+            s = s + '\n' + engine_str + et + ': ' + str(ev)
         return s

     def print_tracebacks(self, excid=None):
@@ -154,7 +154,8 @@
         except:
             raise IndexError("an exception with index %i does not exist"%excid)
         else:
-            raise et, ev, etb
+            msg = "%s | %s | %s" % (et, ev, etb)
+            raise Exception(msg)

 def collect_exceptions(rlist, method):
     elist = []



And now if I run the following script:

--------------
import sys

def fails():
    e = 1/0

from IPython.kernel import client
mec = client.MultiEngineClient()
mec.reset()
ids = mec.get_ids()
mec.push_function({"f": fails})
try:
    print mec.execute("get_tests()")
except:
    t, v, tr = sys.exc_info()
    print v
    v.raise_exception()
----------

I get:

/usr/lib/python2.6/dist-packages/twisted/python/filepath.py:12:
DeprecationWarning: the sha module is deprecated; use the hashlib
module instead
  import sha
/usr/lib/python2.6/dist-packages/foolscap/banana.py:2:
DeprecationWarning: the sets module is deprecated
  import struct, sets, time
one or more exceptions from call to method: execute
[Engine Exception]exceptions.NameError: global name '__IPYTHON__' is not defined
[Engine Exception]exceptions.NameError: global name '__IPYTHON__' is not defined
[Engine Exception]exceptions.NameError: global name '__IPYTHON__' is not defined
[Engine Exception]exceptions.NameError: global name '__IPYTHON__' is not defined
[Engine Exception]exceptions.NameError: global name '__IPYTHON__' is not defined
[Engine Exception]exceptions.NameError: global name '__IPYTHON__' is not defined
[Engine Exception]exceptions.NameError: global name '__IPYTHON__' is not defined
[Engine Exception]exceptions.NameError: global name '__IPYTHON__' is not defined
Traceback (most recent call last):
  File "q.py", line 16, in <module>
    v.raise_exception()
  File "/home/ondrej/lib/lib/python/IPython/kernel/error.py", line
158, in raise_exception
    raise Exception(msg)
Exception: exceptions.NameError | global name '__IPYTHON__' is not
defined | None


So this is some progress -- basically some code tries to use
__IPYTHON__, which is not defined.


Anyway, it seems it is all caused by using python2.6. The problem is
that even if I run

$ python2.5 ~/lib/bin/ipcluster local -n 8
2009-03-18 20:32:53-0700 [-] Log opened.
2009-03-18 20:32:53-0700 [-] Process ['ipcontroller',
'--logfile=/home/ondrej/.ipython/log/ipcontroller'] has started with
pid=17407
2009-03-18 20:32:53-0700 [-]
'/usr/lib/python2.6/dist-packages/twisted/python/filepath.py:12:
DeprecationWarning: the sha module is deprecated; use the hashlib
module instead\n  import sha\n'
[...]

It still seems it still runs python2.6, inferring from the deprecation
warnings. :(

So I decided to do small steps. So I reverted all my local changed and
tried to get the testsuite run. It seems that it fails at many places:

$ scripts/iptest
/var/lib/python-support/python2.6/nose/plugins/manager.py:386:
UserWarning: Module nose was already imported from
/var/lib/python-support/python2.6/nose/__init__.py, but
/var/lib/python-support/python2.6 is being added to sys.path
  import pkg_resources
/usr/lib/python2.6/dist-packages/twisted/python/filepath.py:12:
DeprecationWarning: the sha module is deprecated; use the hashlib
module instead
  import sha
>print(x)
/usr/lib/python2.6/dist-packages/foolscap/banana.py:2:
DeprecationWarning: the sets module is deprecated
  import struct, sets, time
>print('hello')
>print('hello')
>print(repr(_))
.............................S......................................../usr/lib/python2.6/dist-packages/twisted/trial/unittest.py:1350:
DeprecationWarning: Reactor already running! This behavior is
deprecated since Twisted 8.0
  reactor.run()
.....................................................................................................................ERROR:
An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (43, 0))

..................................................................ERROR:
An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (43, 0))

....Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 522, in __bootstrap_inner
    self.run()
  File "/home/ondrej/repos/ipython/IPython/kernel/twistedutil.py",
line 42, in run
    reactor.run(installSignalHandlers=0)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py",
line 1128, in run
    self.mainLoop()
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py",
line 1137, in mainLoop
    self.runUntilCurrent()
--- <exception caught here> ---
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py",
line 729, in runUntilCurrent
    f(*a, **kw)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py",
line 269, in errback
    self._startRunCallbacks(fail)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py",
line 298, in _startRunCallbacks
    raise AlreadyCalledError
twisted.internet.defer.AlreadyCalledError:
ETraceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 522, in __bootstrap_inner
    self.run()
  File "/home/ondrej/repos/ipython/IPython/kernel/twistedutil.py",
line 42, in run
    reactor.run(installSignalHandlers=0)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py",
line 1128, in run
    self.mainLoop()
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py",
line 1137, in mainLoop
    self.runUntilCurrent()
--- <exception caught here> ---
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py",
line 729, in runUntilCurrent
    f(*a, **kw)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py",
line 269, in errback
    self._startRunCallbacks(fail)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py",
line 298, in _startRunCallbacks
    raise AlreadyCalledError
twisted.internet.defer.AlreadyCalledError:
ETraceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/twisted/trial/unittest.py",
line 1195, in runThunk
    self._wait(d)
  File "/usr/lib/python2.6/dist-packages/twisted/trial/unittest.py",
line 1350, in _wait
    reactor.run()
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py",
line 1128, in run
    self.mainLoop()
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py",
line 1137, in mainLoop
    self.runUntilCurrent()
--- <exception caught here> ---
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py",
line 729, in runUntilCurrent
    f(*a, **kw)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py",
line 269, in errback
    self._startRunCallbacks(fail)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py",
line 298, in _startRunCallbacks
    raise AlreadyCalledError
twisted.internet.defer.AlreadyCalledError:
E.....................................................ERROR: An
unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (43, 0))

......./home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
./home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
./home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
./home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
./home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
./home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
./home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
..../home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
.........../home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
../home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
............../home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
................./home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
...../home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
........../home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
../home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
........................./home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
.............../home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
/home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
......./home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
../home/ondrej/repos/ipython/IPython/kernel/error.py:110:
DeprecationWarning: BaseException.message has been deprecated as of
Python 2.6
  self.message = message
...................................S..S.......SS..SSS.........sh:
ipython: not found
F....SSS....
======================================================================
ERROR: testExecuteFailuresEngineService_0
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py",
line 729, in runUntilCurrent
    f(*a, **kw)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py",
line 269, in errback
    self._startRunCallbacks(fail)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py",
line 298, in _startRunCallbacks
    raise AlreadyCalledError
AlreadyCalledError

======================================================================
ERROR: testExecuteFailuresEngineService_1
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py",
line 729, in runUntilCurrent
    f(*a, **kw)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py",
line 269, in errback
    self._startRunCallbacks(fail)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py",
line 298, in _startRunCallbacks
    raise AlreadyCalledError
AlreadyCalledError

======================================================================
ERROR: testExecuteFailuresEngineService_2
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py",
line 729, in runUntilCurrent
    f(*a, **kw)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py",
line 269, in errback
    self._startRunCallbacks(fail)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py",
line 298, in _startRunCallbacks
    raise AlreadyCalledError
AlreadyCalledError

======================================================================
FAIL: Test that object's __del__ methods are called on exit.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/lib/python-support/python2.6/nose/case.py", line 182, in runTest
    self.test(*self.arg)
  File "/home/ondrej/repos/ipython/IPython/tests/test_magic.py", line
88, in test_obj_del
    nt.assert_equals(out,'object A deleted')
AssertionError: '' != 'object A deleted'
>>  raise self.failureException, \
          (None or '%r != %r' % ('', 'object A deleted'))


----------------------------------------------------------------------
Ran 511 tests in 50.749s

FAILED (SKIP=11, errors=3, failures=1)
Deleting object: second_pass
object A deleted
deleting object...



So I am now looking at how to fix it, so that it runs. Then I can see
what I can do about my problem.

Ondrej



More information about the IPython-dev mailing list