On Mar 11, 2010, at 1:20 PM, Lisandro Dalcin wrote: > On 11 March 2010 18:05, Robert Bradshaw > <[email protected]> wrote: >> On Mar 11, 2010, at 12:58 PM, Lisandro Dalcin wrote: >> >>> On 11 March 2010 17:42, Robert Bradshaw >>> <[email protected]> wrote: >>>> >>>> As for the refnanny ones, >>>> >>>> http://hg.cython.org/cython-devel/rev/3045d63c5f14 >>>> >>> >>> Can you explain me the magics behind: >>> >>> try: >>> .... >>> except object, e: >>> ..... >>> >>> I cannot get it ... >> >> >> In Python 2.5+, all errors that are raised are subclasses of >> BaseException, but that doesn't exist in 2.3 or 2.4, hence "object" >> which will catch anything (and still give us the e). > > What are you talking about? See this: > > [dalc...@trantor tmp]$ cat exc.pyx > def main(): > try: > raise ValueError > except object, e: > pass > [dalc...@trantor tmp]$ python -c 'import pyximport; > pyximport.install(); import exc; exc.main()' > Traceback (most recent call last): > File "<string>", line 1, in <module> > File "exc.pyx", line 3, in exc.main > (/u/dalcinl/.pyxbld/temp.linux-i686-2.6/pyrex/exc.c:430) > raise ValueError > ValueError
Hmm... I thought that "except X" would catch all exceptions that were subclasses of X, but it turns out that it doesn't check inheritance unless X is an exception type... I'll fix this. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
