Repository navigation
Closed
Description
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 = None
closed_at = <Date 2017-03-15.12:52:09.446>
created_at = <Date 2016-09-21.07:31:34.259>
labels = ['3.7', 'type-bug', 'library']
title = 'tarfile does not support pathlib'
updated_at = <Date 2017-03-24.22:41:49.995>
user = 'https://github.com/ethanfurman'bugs.python.org fields:
activity = <Date 2017-03-24.22:41:49.995>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = True
closed_date = <Date 2017-03-15.12:52:09.446>
closer = 'berker.peksag'
components = ['Library (Lib)']
creation = <Date 2016-09-21.07:31:34.259>
creator = 'ethan.furman'
dependencies = []
files = ['44772', '45042', '45051']
hgrepos = []
issue_num = 28230
keywords = ['patch']
message_count = 9.0
messages = ['278414', '278416', '278428', '278444', '288604', '289096', '289671', '290265', '290267']
nosy_count = 6.0
nosy_names = ['brett.cannon', 'lars.gustaebel', 'ned.deily', 'ethan.furman', 'berker.peksag', 'serhiy.storchaka']
pr_nums = ['512', '559']
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue28230'
versions = ['Python 3.6', 'Python 3.7']
Activity
berkerpeksag commentedon Oct 10, 2016
Here's an updated patch with different tests and documentation changes. I simplified Lib/tarfile.py a bit (see my review comments)
A slightly off-topic question: I had to update both docstrings and documentation. Should we use this as an opportunity to simplify the docstrings?
serhiy-storchaka commentedon Oct 10, 2016
There are two kinds of paths in tarinfo:
External paths that correspond to filesystem paths. The path of the tar file itself, patches of added files and target directory for extraction. Supporting path protocol looks reasonable for them.
Internal paths, they are just string keys inside an archive. They come from TarFile.getnames() and always are strings. I'm not sure that pathlib have relation to this. This issue needs more thoughts. I would not haste with this.
ethanfurman commentedon Oct 10, 2016
As Serhiy was alluding to, if the incoming path is for the actual tar file and is only passed along to Python itself then we probably don't need to worry about os.fspath(). For names that will be interally stored, or are for accessing internal files, then the proper sequence is check for and call os.fspath if necessary, and then double-check that the name to be used is a str. The double-check is needed because os.fspath may return a bytes object, which tar does not allow.
serhiy-storchaka commentedon Oct 10, 2016
It seems to me that tarfile already supports path protocol for all external patches and no changes for tarfile are needed.
Proposed patch adds tests for (already implemented) support of pathlike protocol in tarfile.
berkerpeksag commentedon Feb 26, 2017
Serhiy's patch looks good to me, but it would be nice to document the support for PathLike objects in the tarfile documentation.
serhiy-storchaka commentedon Mar 6, 2017
Updated documentation.
Note that path-like objects are supported only for external names. Internal names are not OS paths.
berkerpeksag commentedon Mar 15, 2017
PR 512 has been merged and backported to 3.6 branch. I think this can be closed now. Thanks, Ethan and Serhiy!
serhiy-storchaka commentedon Mar 24, 2017
New changeset 666165f by Serhiy Storchaka in branch '3.6':
[3.6] bpo-28230: Document the pathlib support in tarfile and add tests. (#559)
666165f
serhiy-storchaka commentedon Mar 24, 2017
New changeset c45cd16 by Serhiy Storchaka in branch 'master':
bpo-28230: Document the pathlib support in tarfile and add tests. (#512)
c45cd16