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:

  try:
     fsp = obj.__fspath__
  except AttributeError:
     pass
  else:
     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:

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

Certainly not code I want to see in the stdlib.

--
~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to