[MERGE] Add exit() on progressbars from TestUIFactory

Martin Pool mbp at sourcefrog.net
Tue Mar 17 01:53:07 GMT 2009


2009/3/17 Robert Collins <robert.collins at canonical.com>:
> It has the disadvantage that it doesn't work :(.
>
> Python simply fails to tell you that it won't.

I was a bit worried by this because we already have some code that
does this and claims to do it because of python2.4.  But it looks like
it does work:

mbp at grace% cat ~/tmp/generator.py
def a(crash):
    try:
        for i in range(5):
            yield 2*i
        if crash:
            raise AssertionError()
    except:
        print 'foo'
        raise
    else:
        print 'done'

print list(a(False))
print list(a(True))
mbp at grace% python2.4 ~/tmp/generator.py
done
[0, 2, 4, 6, 8]
foo
Traceback (most recent call last):
  File "/home/mbp/tmp/generator.py", line 14, in ?
    print list(a(True))
  File "/home/mbp/tmp/generator.py", line 6, in a
    raise AssertionError()
AssertionError


-- 
Martin <http://launchpad.net/~mbp/>



More information about the bazaar mailing list