[New-bugs-announce] [issue10761] tarfile.extractall fails to overwrite symlinks

Sridhar Ratnakumar report at bugs.python.org
Thu Dec 23 01:17:16 CET 2010

New submission from Sridhar Ratnakumar <sridharr at activestate.com>:

tarfile.extractall overwrites normal files and directories, yet it fails to overwrite symlinks:

  File "/opt/ActivePython-2.7/lib/python2.7/tarfile.py", line 2046, in extractall
    self.extract(tarinfo, path)
  File "/opt/ActivePython-2.7/lib/python2.7/tarfile.py", line 2083, in extract
    self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
  File "/opt/ActivePython-2.7/lib/python2.7/tarfile.py", line 2167, in _extract_member
    self.makelink(tarinfo, targetpath)
  File "/opt/ActivePython-2.7/lib/python2.7/tarfile.py", line 2243, in makelink
    os.symlink(tarinfo.linkname, targetpath)
OSError: [Errno 17] File exists

To reproduce, use a .tar.gz file containing relative (i.e., in the same directory) symlinks.

Perhaps it should delete `targetpath` before attempting to create a symlink.

components: Library (Lib)
messages: 124523
nosy: srid
priority: normal
severity: normal
status: open
title: tarfile.extractall fails to overwrite symlinks
type: behavior
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list