Repository navigation
add os.fspath() #71373
Copy link
Copy link
Closed
Labels
type-featureA feature request or enhancementA feature request or enhancement
Description
| BPO | 27186 |
|---|---|
| Nosy | @brettcannon, @ethanfurman, @vadmium, @serhiy-storchaka, @JelleZijlstra, @buchuki, @erikjanss |
| Files |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = 'https://github.com/brettcannon'
closed_at = <Date 2016-06-24.19:28:56.707>
created_at = <Date 2016-06-02.18:22:21.760>
labels = ['type-feature']
title = 'add os.fspath()'
updated_at = <Date 2018-08-13.23:04:39.687>
user = 'https://github.com/ethanfurman'bugs.python.org fields:
activity = <Date 2018-08-13.23:04:39.687>
actor = 'erikjanss'
assignee = 'brett.cannon'
closed = True
closed_date = <Date 2016-06-24.19:28:56.707>
closer = 'brett.cannon'
components = []
creation = <Date 2016-06-02.18:22:21.760>
creator = 'ethan.furman'
dependencies = []
files = ['43124', '43125', '43128', '43133', '43155', '43205', '43215']
hgrepos = []
issue_num = 27186
keywords = ['patch']
message_count = 45.0
messages = ['266971', '266979', '266982', '266984', '267004', '267105', '267127', '267285', '267293', '267295', '267299', '267301', '267306', '267316', '267322', '267327', '267328', '267336', '267348', '267429', '267465', '268060', '268062', '268070', '268146', '268158', '268329', '268393', '268394', '268399', '268414', '268415', '268433', '268457', '268628', '269204', '269205', '269207', '269208', '269209', '269795', '269800', '323225', '323228', '323495']
nosy_count = 8.0
nosy_names = ['brett.cannon', 'ethan.furman', 'python-dev', 'martin.panter', 'serhiy.storchaka', 'JelleZijlstra', 'buchuki', 'erikjanss']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue27186'
versions = ['Python 3.6']Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type-featureA feature request or enhancementA feature request or enhancement
Activity
python-dev commentedon Jun 2, 2016
New changeset 59a52a9dd0dc by Ethan Furman in branch 'default':
bpo-27186 -- initial docs, tests, and python version of os.fspath
https://hg.python.org/cpython/rev/59a52a9dd0dc
buchuki commentedon Jun 2, 2016
Make os.fsencode and os.fsdecode able to accept a PathLike by calling into fspath. Additionally adds test for PathLike objects.
buchuki commentedon Jun 2, 2016
Test __fspath__ returning bytes as well.
JelleZijlstra commentedon Jun 2, 2016
This patch adds the C implementation (copied from the PEP).
Some notes:
buchuki commentedon Jun 3, 2016
This patch adds fspath protocol and constructor initialization to pathlib.Path.
ethanfurman commentedon Jun 3, 2016
Note: My schedule changed -- I won't be at the sprints today, but tomorrow. I'll finish reviewing these patches and commit this afternoon if no one beats me to it.
buchuki commentedon Jun 3, 2016
Adding a glossary entry for path-like. The references are all correct except:
:class:`os.PathLike` doesn't link to anything because PathLike hasn't been added to the os module yet. Similarly, :meth:`__fspath__` does not link to anything, although I think this is acceptable.
ethanfurman commentedon Jun 4, 2016
Dusty: The pathlib tests looks like it's only testing the PurePath implementation; while this /should/ be sufficient, please add tests for the other classes as well.
python-dev commentedon Jun 4, 2016
New changeset 780cbe18082e by Ethan Furman in branch 'default':
bpo-27186: add C version of os.fspath(); patch by Jelle Zijlstra
https://hg.python.org/cpython/rev/780cbe18082e
ethanfurman commentedon Jun 4, 2016
New changeset 00991aa5fdb5 by Ethan Furman in branch 'default':
bpo-27182: update fsencode and fsdecode for os.path(); patch by Dusty Phillips
https://hg.python.org/cpython/rev/00991aa5fdb5
(had wrong issue # in commit)
ethanfurman commentedon Jun 4, 2016
Jelle: the DirEntry patch looks good so far, but it needs a test for a bytes path.
JelleZijlstra commentedon Jun 4, 2016
Thanks for reviewing. This patch adds tests with a bytes DirEntry.
python-dev commentedon Jun 4, 2016
New changeset e672cf63d08a by Ethan Furman in branch 'default':
bpo-27186: add PathLike ABC
https://hg.python.org/cpython/rev/e672cf63d08a
python-dev commentedon Jun 4, 2016
New changeset 76b2ddaee6bd by Ethan Furman in branch 'default':
bpo-27186: fix fsencode/fsdecode and update tests; patch by Jelle Zijlstra
https://hg.python.org/cpython/rev/76b2ddaee6bd
21 remaining items
vadmium commentedon Jun 13, 2016
I went with os.name == "nt", which is what other scandir() tests use. I’m not sure there is a practical different. Anyway the buildbots seem happier now.
brettcannon commentedon Jun 13, 2016
Thanks for catching my screw-up, Martin; I misread the checks in the file by noticing the "nt" bit but not picking up it was comparing against sys.name instead of sys.platform.
ethanfurman commentedon Jun 15, 2016
os.fspath() will be changed to ensure the output of calling obj.__fspath__() is a str or bytes object.
So the final behavior of calling os.fspath() will be to return a str or bytes or to raise an exception.
I'll update the code for this change, as well is the places in the stdlib that do/should be using os.fspath().
python-dev commentedon Jun 24, 2016
New changeset ea7b6a7827a4 by Brett Cannon in branch 'default':
Issue bpo-27186: Update os.fspath()/PyOS_FSPath() to check the return
https://hg.python.org/cpython/rev/ea7b6a7827a4
brettcannon commentedon Jun 24, 2016
And now that I have updated os.fspath() I realize that Ethan said he was going to implement the update. :( If you started on the work, Ethan, I'm really sorry for duplicating your (potential) work.
I'm going to commit Dusty's glossary term next and then go through and update the docs to use it. At that point that will leave updating os.path as the last explicit step in PEP-519 that needs to be short of updating "What's New". We're getting there. :)
python-dev commentedon Jun 24, 2016
New changeset 9c57178f13dc by Brett Cannon in branch 'default':
Issue bpo-27186: Define what a "path-like object" is.
https://hg.python.org/cpython/rev/9c57178f13dc
brettcannon commentedon Jun 24, 2016
I think with the glossary change, this issue is done! Thanks everyone for the help with getting this far!
Now on to os.path...
ethanfurman commentedon Jun 24, 2016
Brett, no worries. My time has been extremely limited.
I'll get the other locations in the stdlib fixed sometime in the next two months if no one beats me to it.
serhiy-storchaka commentedon Jul 4, 2016
Maybe merge Include/osmodule.h and Modules/posixmodule.h?
brettcannon commentedon Jul 4, 2016
I'm fine with merging the two files if you want to do it. Build rules will also need updating if they do get merged.
erikjanss commentedon Aug 6, 2018
is there a particular reason for PyOS_FSPath to live in posixmodule.c
since Objects/unicodeobject.c uses this function, this makes it not possible to compile Python without a posixmodule.
this makes it difficult to compile a 'core' python on a new platform, since implementing the posixmodule on a new platform is not trivial.
also the documentation on porting mentions that one should first port python without a posixmodule.
brettcannon commentedon Aug 6, 2018
On Mon, Aug 6, 2018, 13:56 Erik Janssens, <[email protected]> wrote:
It's there because the C API for the os module is kept in that module.
erikjanss commentedon Aug 13, 2018
thank you for the info ... I'll have a look at making the posix module easier to port ...