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

Also, add tests common to tarfile and zipfile.
5 files changed