[3.12] gh-114959: tarfile: do not ignore errors when extract a directory on top of a file (GH-114960) (GH-114963)

Also, add tests common to tarfile and zipfile.
(cherry picked from commit 96bce033c4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-02-03 17:39:01 +01:00 committed by GitHub
parent c86a9e662f
commit 8ed20bc8bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 220 additions and 1 deletions

View file

@ -2449,7 +2449,8 @@ class TarFile(object):
# later in _extract_member().
os.mkdir(targetpath, 0o700)
except FileExistsError:
pass
if not os.path.isdir(targetpath):
raise
def makefile(self, tarinfo, targetpath):
"""Make a file called targetpath.