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~
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4