[Python-Dev] pathlib - current status of discussions

Ethan Furman ethan at stoneleaf.us
Wed Apr 13 20:29:19 EDT 2016

On 04/13/2016 05:06 PM, Chris Barker wrote:

> In this case, I don't know that we need to be tolerant of buggy
> __fspathname__() implementations -- they should be tested outside these
> checks, and not be buggy. So a buggy implementation may raise and may be
> ignored, depending on what Exception the bug triggers -- big deal. The
> only time it would matter is when the implementer is debugging the
> implementation.

Yet the idea behind robust exception handling is to test as little as 
possible and only catch what you know how to correct.

This code catches only one thing, only at one place, and we know how to 
deal with it:

      fsp = obj.__fspath__
   except AttributeError:
      fsp = fsp()

Contrarily, this next code catches the same error, but it could happen 
at the one place we know how to deal with it *or* anywhere further down 
the call stack where we have no clue what the proper course is to handle 
the problem... yet we suppress it anyway:

     fsp = obj.__fspath__()
   except AttributeError:

Certainly not code I want to see in the stdlib.


More information about the Python-Dev mailing list