FAQ
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.
from abc import ABCMeta
class RootException(Exception,metaclass«CMeta): pass
...
class MyException(Exception): pass
...
RootException.register(MyException)
try:
... 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

Search Discussions

  • Chris Rebert at May 8, 2011 at 2:03 am

    On Sat, May 7, 2011 at 12:03 PM, andrew cooke wrote:
    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.
    from abc import ABCMeta
    class RootException(Exception,metaclass«CMeta): pass
    ...
    class MyException(Exception): pass
    ...
    RootException.register(MyException)
    try:
    ... ? ? 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
  • Andrew cooke at May 8, 2011 at 8:55 am

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMay 7, '11 at 7:03p
activeMay 8, '11 at 8:55a
posts3
users2
websitepython.org

2 users in discussion

Andrew cooke: 2 posts Chris Rebert: 1 post

People

Translate

site design / logo © 2022 Grokbase