Title: tarfile list() method does not show file type
Type: behavior Stage:
Components: Versions: Python 3.8, Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: ethan.furman Nosy List: andrei.avk, ethan.furman, val.shkolnikov
Priority: normal Keywords:

Created on 2021-02-02 04:35 by val.shkolnikov, last changed 2021-12-07 21:18 by val.shkolnikov.

File name Uploaded Description Edit
patch val.shkolnikov, 2021-02-02 04:35
Messages (4)
msg386129 - (view) Author: Val Shkolnikov (val.shkolnikov) * Date: 2021-02-02 04:35
The list() method of TarFile tarfile object shows question mark in place of file type in verbose mode. For instance
python3 -m tarfile -v -l my.tar
?rwxr-xr-x vals/users          0 2021-01-16 18:28:30 bin/
?rwxr-x--- vals/users        266 2021-01-16 18:28:30 bin/
?rwxr-xr-x vals/users        950 2018-01-02 10:39:18 bin/
?rwxrwxrwx vals/users          0 2021-01-16 11:49:36 bin/source-highlight -> ../source-highlight/bin/source-highlight
?rwxr-xr-x vals/users        435 2011-03-27 15:38:06 bin/

This is because the call stat.filemode(tarinfo.mode) does not pass tarinfo.type to stat.filemode. The type needs to be properly encoded and added to the argument.

My patch is attached. Verified under Linux, Cygwin and Windows.
msg397039 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-07-06 14:02
I've tested this patch on OS X with symbolic links, dirs, files and it works fine.
msg407643 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-12-04 06:52
Val: contributions are only now accepted in form of github PRs, not patches.
msg407971 - (view) Author: Val Shkolnikov (val.shkolnikov) * Date: 2021-12-07 21:18
> contributions are only now accepted in form of github PRs
Date User Action Args
2021-12-07 21:18:14val.shkolnikovsetmessages: + msg407971
2021-12-04 06:52:35andrei.avksetmessages: + msg407643
2021-07-06 14:02:15andrei.avksetnosy: + andrei.avk
messages: + msg397039
2021-02-24 01:12:27ethan.furmansetassignee: ethan.furman

nosy: + ethan.furman
2021-02-02 04:35:47val.shkolnikovcreate