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
tarfile does not support pathlib #72417
Comments
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? |
There are two kinds of paths in tarinfo:
|
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. |
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. |
Serhiy's patch looks good to me, but it would be nice to document the support for PathLike objects in the tarfile documentation. |
Updated documentation. Note that path-like objects are supported only for external names. Internal names are not OS paths. |
PR 512 has been merged and backported to 3.6 branch. I think this can be closed now. Thanks, Ethan and Serhiy! |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: