Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
May 5, 2017

Conversation

JelleZijlstra
Copy link
Member

No description provided.

@mention-bot
Copy link

@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
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!

Lib/shutil.py Outdated
@@ -958,6 +958,8 @@ def unpack_archive(filename, extract_dir=None, format=None):
if extract_dir is None:
extract_dir = os.getcwd()

filename = os.fspath(filename)
Copy link
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
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
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
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
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
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
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
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
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