This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brett.cannon
Recipients JelleZijlstra, brett.cannon, ethan.furman, python-dev, serhiy.storchaka
Date 2016-06-05.18:45:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1465152340.0.0.656435193138.issue27182@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2016-06-05 18:45:40brett.cannonsetrecipients: + brett.cannon, ethan.furman, python-dev, serhiy.storchaka, JelleZijlstra
2016-06-05 18:45:40brett.cannonsetmessageid: <1465152340.0.0.656435193138.issue27182@psf.upfronthosting.co.za>
2016-06-05 18:45:39brett.cannonlinkissue27182 messages
2016-06-05 18:45:39brett.cannoncreate