Brett Cannon added the comment: Functions that only accept file descriptors should not be updated to work with __fspath__() as it will never return an int/fd.
As for Ethan's suggestion, are you saying you want to toss the str/bytes check from os.fspath()? If so then you will need to go to python-dev and bring that up as the PEP clearly specifies that str/bytes is checked for and specifically in the order of the Python code. The thinking behind the current design is that since __fspath__() has to be explicitly implemented that people will do so properly, versus accidentally passing in some type that isn't str/bytes like the pre-PEP 519 world (i.e. trust the __fspath__() implementors to do the right thing and only protect against someone passing in something wrong from complicated code flow). There has been discussion about using the ``path.__fspath__() if hasattr(path, '__fspath__') else path`` idiom in os.path so that the pre-existing type-checks can do their thing instead of checking twice, although that's different from how os.fspath() works (then again, since this is all new code we could argue that going our own route in os.path is acceptable in the name of performance). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27182> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com