How can an Exception pass over an "except" clause ?

Nebur nospam1.reifenberg at gmx.de
Wed May 30 11:46:50 EDT 2007


I'm using the contract.py library, running Python 2.4.4.

Now I'm confronted with the following exception backtrace:
 (...)
  File "/usr/lib/python2.4/site-packages/contract.py", line 1265, in
_check_preconditions
    p = f.__assert_pre
AttributeError: 'function' object has no attribute '__assert_pre'

For my surprise, I found that the code of contract.py around line 1265
looks like:

1264: try:
1265:     p = f.__assert_pre
1266: except AttributeError:
1267:     pass

I'd expect line 1267 to "swallow" the AttributeError siliently. But
the application stops with the above backtrace.
Someone familiar enough with the Python innards ? How can one manage
that an "except" seems to be ignored ?

 Ruben




More information about the Python-list mailing list