Skip to content

bpo-30218: support PathLike in shutil.unpack_archive#1367

Merged
brettcannon merged 5 commits into
python:masterfrom
JelleZijlstra:unpackpath
May 5, 2017
Merged

bpo-30218: support PathLike in shutil.unpack_archive#1367
brettcannon merged 5 commits into
python:masterfrom
JelleZijlstra:unpackpath

Conversation

@JelleZijlstra
Copy link
Copy Markdown
Member

No description provided.

@mention-bot
Copy link
Copy Markdown

@JelleZijlstra, thanks for your PR! By analyzing the history of the files in this pull request, we identified @serhiy-storchaka, @hynek and @larryhastings to be potential reviewers.

Copy link
Copy Markdown
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor thing, otherwise LGTM!

Comment thread Lib/shutil.py
if extract_dir is None:
extract_dir = os.getcwd()

filename = os.fspath(filename)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that the tests show extract_dir working for a path-like object, but there's no explicit conversion here. If it's because something else explicitly covers that then please add a comment. Otherwise just explicitly do the os.fspath() conversion for extract_dir.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it works because it's only passed to other functions that already accept PathLikes. However, it is passed to a handler function that is specific to a file format and maybe some handlers don't accept PathLike, so I'll just add os.fspath for it anyway.

@brettcannon
Copy link
Copy Markdown
Member

Do the docs need updating to mention path-like support?

@brettcannon brettcannon added the type-bug An unexpected behavior, bug, or error label May 1, 2017
@JelleZijlstra
Copy link
Copy Markdown
Member Author

Not sure about the docs; my thinking is that every function using a path should support PathLike in 3.6 and up, so there's no point in explicitly noting it. But I'm open to adding it if you prefer being explicit.

@brettcannon
Copy link
Copy Markdown
Member

I was asking more in case the docs specifically mention that the arguments are expected to be a string or something like shutil.copyfile()'s documentation (opened bpo-30235 to track that). Since the docs don't phrase things that way for unpack_archive() it's fine. So just address the one review comment and this can then be merged and backported.

@brettcannon brettcannon self-assigned this May 2, 2017
@brettcannon
Copy link
Copy Markdown
Member

Just realized I forgot to ask if you could you add an entry to Misc/NEWS for this, @JelleZijlstra ? And don't put the entry at the top of the section to minimize potential merge conflicts.

@brettcannon
Copy link
Copy Markdown
Member

Now I just have to decide if this a bugfix or not. 🤔 I don't remember off the top of my head if we decided that os.PathLike support was considered a bugfix or not.

@brettcannon
Copy link
Copy Markdown
Member

After discussing things on python-dev, this has been flagged as an enhancement, hence a need to at least add a versionchanged mention in the docs (e.g. "Added support for path-like objects.").

Sorry for all the little edits on this, @JelleZijlstra .

@berkerpeksag
Copy link
Copy Markdown
Member

I think a documentation change is needed. We've updated the documentation even if the module was already (indirectly) accept path-like objects.

@brettcannon brettcannon added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels May 5, 2017
@brettcannon brettcannon merged commit a12df7b into python:master May 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants