[New-bugs-announce] [issue7101] tarfile: OSError with TarFile.add(..., recursive=True) about non-existing file

Denis Martinez report at bugs.python.org
Sun Oct 11 01:49:22 CEST 2009

New submission from Denis Martinez <deuns.martinez at gmail.com>:

I have written a server backup script (file attached) which archives a
list of directories with tarfile and uploads the file to FTP. Today, the
script hanged, with an exception:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 525, in __bootstrap_inner
  File "./backup.py", line 48, in run
    tar.add(file_or_directory, recursive=True)
  File "/usr/lib/python2.6/tarfile.py", line 1981, in add
    self.add(os.path.join(name, f), os.path.join(arcname, f), recursive,
  File "/usr/lib/python2.6/tarfile.py", line 1965, in add
    tarinfo = self.gettarinfo(name, arcname)
  File "/usr/lib/python2.6/tarfile.py", line 1834, in gettarinfo
    statres = os.lstat(name)
OSError: [Errno 2] No such file or directory: '/srv/myfile.htdigest'

What I did here is that I removed the htdigest file while the tarfile
was archiving /srv. I haven't managed to reproduce the bug a second time.
It seems normal that tarfile shouldn't fail is this case; maybe it needs
some exception checking around the stat/lstat calls.

components: Library (Lib)
files: backup2.py
messages: 93845
nosy: denis
severity: normal
status: open
title: tarfile: OSError with TarFile.add(..., recursive=True) about non-existing file
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file15098/backup2.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list