AssertionError not caught?

Alexander Kain lxkain at gmail.com
Sun Feb 1 21:51:53 EST 2009


Thank you for restoring sanity to my world!

Indeed, it seems to have to do with the way that the WingIDE debugger  
works - it actually catches the error correctly , but it -->sets a  
breakpoint at the original raise first<---. This only occurs for the  
AssertionError. The debugger can then be continued.

Thank you again!

On Feb 1, 2009, at 6:44 PM, Chris Rebert wrote:

> On Sun, Feb 1, 2009 at 6:31 PM, LX <lxkain at gmail.com> wrote:
>> This one has me mystified good!
>>
>> This works (print statement is executed as the Exception is caught)  
>> as
>> advertised:
>>   try:
>>       raise AssertionError
>>   except AssertionError:
>>       print "caught AssertionError"
>>
>>
>> But this one does not:
>>
>>  def test():
>>       raise AssertionError
>>
>>   try:
>>       test()
>>   except AssertionError:
>>       print "caught AssertionError"
>>
>> other errors (e.g. IOError) work fine! This is on OSX 10.5.6, with  
>> the
>> standard Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
>> [GCC 4.0.1 (Apple Computer, Inc. build 5341)].
>>
>> Is this a bug? Any hints / help would be much appreciated! Thank you.
>
> My Mac begs to differ:
>
> ~ $ cat Desktop/tmp.py
> def test():
>   raise AssertionError
>
> try:
>   test()
> except AssertionError:
>   print "caught AssertionError"
> ~ $ /System/Library/Frameworks/Python.framework/Versions/2.5/bin/ 
> python2.5
> Desktop/tmp.py
> caught AssertionError
> ~ $ /System/Library/Frameworks/Python.framework/Versions/2.5/bin/ 
> python2.5
> Python 2.5.1 (r251:54863, Feb  4 2008, 21:48:13)
> [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
>
> The problem must lie elsewhere.
>
> Cheers,
> Chris
>
> -- 
> Follow the path of the Iguana...
> http://rebertia.com




More information about the Python-list mailing list