This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: TarFile.add skips files when tarfile name matches a directory
Type: Stage:
Components: Library (Lib) Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ethan.furman, jkinkead
Priority: normal Keywords:

Created on 2021-10-18 20:37 by jkinkead, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
repro.py jkinkead, 2021-10-18 20:37 Reproduction script
Messages (1)
msg404217 - (view) Author: Jesse Kinkead (jkinkead) Date: 2021-10-18 20:37
tarfile.open has a "name" parameter that can be used to open a file for reading or writing in the local filesystem. The documentation is unclear what the purpose is if providing a "fileobj" parameter as well, but it has very surprising behavior when the name matches an existing directory.

Specifically, when you provide a "fileobj" for writing and provide a "name" that matches an existing directory, calling .add() on that directory will have it (and any child files) to be silently skipped.

The desired behavior is either to have the files be added (consistent with "name" being totally ignored), or to have it be an error to provide such a "name" value (either one that matches an existing directory, or to provide one at all when using "fileobj").
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89680
2021-10-18 20:47:42ethan.furmansetnosy: + ethan.furman
2021-10-18 20:37:06jkinkeadcreate