Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4931
| References | <69a952d2-55c8-4328-85de-47f51ef53d32@glegroupsg2000goo.googlegroups.com> |
|---|---|
| Date | 2011-05-07 19:03 -0700 |
| Subject | Re: ABC-registered Exceptions are not caught as subclasses |
| From | Chris Rebert <clp2@rebertia.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1301.1304820224.9059.python-list@python.org> (permalink) |
On Sat, May 7, 2011 at 12:03 PM, andrew cooke <andrew@acooke.org> 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=ABCMeta): 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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar
ABC-registered Exceptions are not caught as subclasses andrew cooke <andrew@acooke.org> - 2011-05-07 12:03 -0700 Re: ABC-registered Exceptions are not caught as subclasses Chris Rebert <clp2@rebertia.com> - 2011-05-07 19:03 -0700
csiph-web