[Python-Dev] pathlib - current status of discussions (original) (raw)
Ethan Furman ethan at stoneleaf.us
Wed Apr 13 20:29:19 EDT 2016
- Previous message (by thread): [Python-Dev] pathlib - current status of discussions
- Next message (by thread): [Python-Dev] pathlib - current status of discussions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): [Python-Dev] pathlib - current status of discussions
- Next message (by thread): [Python-Dev] pathlib - current status of discussions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]