ABC-registered Exceptions are not caught as subclasses

A

andrew cooke

This isn't hugely surprising, but doesn't seem to be documented. Is it a bug, or worth raising as one, or have I misunderstood?


Python 3.2 (r32:88445, Feb 27 2011, 13:00:05)
[GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] on linux2
Type "help", "copyright", "credits" or "license" for more information..... raise MyException
.... except RootException:
.... print('caught')
....
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
__main__.MyException

If you assume that the ABC "register" class should work likeinheritance (as it does with issubclass and isinstance then you would, I think, have expected the exception above to have been caught.

Andrew
 
C

Chris Rebert

This isn't hugely surprising, but doesn't seem to be documented.  Isit a bug, or worth raising as one, or have I misunderstood?


Python 3.2 (r32:88445, Feb 27 2011, 13:00:05)
[GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] on linux2
Type "help", "copyright", "credits" or "license" for more information....     raise MyException
... except RootException:
...     print('caught')
...
Traceback (most recent call last):
 File "<stdin>", line 2, in <module>
__main__.MyException

If you assume that the ABC "register" class should work likeinheritance (as it does with issubclass and isinstance then you would, I think, have expected the exception above to have been caught.

Seems worth filing a bug IMO; it probably deserves clarification in
the docs if nothing else, though this behavior isn't inconsistent with
them as they're currently written (due to the vagaries of natural
language).

Cheers,
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top