Skip to content

Commit 7480fcd

Browse files
committed
Python 3.8: tarfile.filemode is gone, use stat.filemode if available
> mode = tarfile.filemode(entry.mode)[1:] E AttributeError: module 'tarfile' has no attribute 'filemode'
1 parent a076378 commit 7480fcd

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

tests/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
from os.path import abspath, dirname, join
77
from stat import S_ISREG
88
import tarfile
9+
try:
10+
from stat import filemode
11+
except ImportError: # Python 2
12+
filemode = tarfile.filemode
913

1014
from libarchive import file_reader
1115

@@ -83,7 +87,7 @@ def get_tarinfos(location):
8387
path += '/'
8488
# libarchive introduces prefixes such as h prefix for
8589
# hardlinks: tarfile does not, so we ignore the first char
86-
mode = tarfile.filemode(entry.mode)[1:]
90+
mode = filemode(entry.mode)[1:]
8791
yield {
8892
'path': path,
8993
'mtime': entry.mtime,

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist=py27,py34,py35,py36
2+
envlist=py27,py34,py35,py36,py37,py38
33
skipsdist=True
44

55
[testenv]

0 commit comments

Comments
 (0)