bpo-21987: Fix TarFile.getmember getting a dir with a trailing slash (GH-30283)

This commit is contained in:
andrei kulakov 2022-01-21 02:40:32 -05:00 committed by GitHub
parent 22f73bd9f1
commit cfadcc31ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View file

@ -1789,7 +1789,7 @@ class TarFile(object):
than once in the archive, its last occurrence is assumed to be the
most up-to-date version.
"""
tarinfo = self._getmember(name)
tarinfo = self._getmember(name.rstrip('/'))
if tarinfo is None:
raise KeyError("filename %r not found" % name)
return tarinfo