[Python-3000] exception-swallowing behaviour of hasattr

Chris Mellon arkanes at gmail.com
Tue Jan 22 18:31:03 CET 2008


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.


More information about the Python-3000 mailing list