Opened 15 years ago

Last modified 15 years ago

#1103 defect closed fixed (fixed)

TypeError in Failure.raiseException when using defer.deferredGenerator and perspective broker

Reported by: titty Owned by:
Priority: high Milestone:
Component: Keywords:
Cc: titty Branch:
Author:

Description


Change History (4)

comment:1 Changed 15 years ago by titty

The following program shows the bug.
Failure.raiseException doesn't handle the case where the exception is a string.


---
last lines of output:

[Failure instance: Traceback: exceptions.TypeError: exceptions must be classes,
instances, or strings (deprecated), not type
/usr/home/ralf/bbot/bb-dir/freebsd/python/twisted/internet/defer.py:261:errback
/usr/home/ralf/bbot/bb-dir/freebsd/python/twisted/internet/defer.py:347:_startRunCallbacks
/usr/home/ralf/bbot/bb-dir/freebsd/python/twisted/internet/defer.py:360:_runCallbacks
/usr/home/ralf/bbot/bb-dir/freebsd/python/twisted/internet/defer.py:685:gotError
--- <exception caught here> ---
/usr/home/ralf/bbot/bb-dir/freebsd/python/twisted/internet/defer.py:654:_deferGenerator
t.py:23:doit
/usr/home/ralf/bbot/bb-dir/freebsd/python/twisted/internet/defer.py:643:getResult
/usr/home/ralf/bbot/bb-dir/freebsd/python/twisted/python/failure.py:250:raiseException
]



-----
#! /usr/bin/env python

from twisted.spread import pb
from twisted.internet import reactor, defer
    
class Echoer(pb.Root):
    def remote_echo(self, st):
        raise NotImplementedError('no')


@defer.deferredGenerator
def doit():
    wait = defer.waitForDeferred
    
    factory = pb.PBClientFactory()
    reactor.connectTCP("127.0.0.1", 8789, factory)
    d = wait(factory.getRootObject())
    yield d
    d = d.getResult()
    
    d=wait(d.callRemote("echo", "foobar"))
    yield d
    d = d.getResult()
    
    
if __name__ == '__main__':
    reactor.listenTCP(8789, pb.PBServerFactory(Echoer()))

    def done(r):
        print r
        reactor.stop()

    doit().addCallbacks(done, done)
    reactor.run()

comment:2 Changed 15 years ago by titty

this bug happens with latest svn version (r14095)

comment:3 Changed 15 years ago by titty

guess this is fixed with r14234

----------------------------------------------------------------------
r627 (orig r14234):  radix | 2005-08-03 07:04:14 +0200
Changed paths:
  M  /mirror/Twisted-trunk/twisted/python/failure.py
  M  /mirror/Twisted-trunk/twisted/test/test_failure.py

don't allow raiseException to totally barf when the failure is wrapping a string
 exception.
use self.type instead of self.value.__class__. teratorn tracked this down.

comment:4 Changed 10 years ago by <automation>

Note: See TracTickets for help on using tickets.