[Python-3000] exception-swallowing behaviour of hasattr

Guido van Rossum guido at python.org
Tue Jan 22 18:36:39 CET 2008


On Jan 22, 2008 9:31 AM, Chris Mellon <arkanes at gmail.com> wrote:
> On Jan 22, 2008 9:36 AM, Guido van Rossum <guido at python.org> wrote:
> > IMO (1) or (2) are both acceptable, but I'd prefer (2): swallow
> > 'Exception'. There's a reason why hasattr() is different from
> > getattr() with a default value; it's too early for me to explain it
> > clearly, but I know it was discussed and argued at length when
> > hasattr() was introduced.
> >
> > I don't see why AssertionError ought to be treated differently than
> > TypeError or any other "regular" error. The key goal here is to avoid
> > swallowing KeyboardInterrupt, and to a lesser extend SystemExit.
> >
> > --Guido
> >
>
> A particularly nasty case is that it swallows RecursionLimitExceededError.

Why is that nastier than other bugs?

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list