[issue9815] test_tarfile sometimes ends with error "Cannot remoe dir"

Hirokazu Yamamoto report at bugs.python.org
Fri Sep 10 09:18:20 CEST 2010

New submission from Hirokazu Yamamoto <ocean-city at m2.ccsnet.ne.jp>:

I noticed regrtest claimed it cannot delete folder after test_tarfile
ran. It was like this.

Traceback (most recent call last):
  File "e:\python-dev\py3k\lib\runpy.py", line 160, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "e:\python-dev\py3k\lib\runpy.py", line 73, in _run_code
    exec(code, run_globals)
  File "e:\python-dev\py3k\lib\test\test_tarfile.py", line 1566, in <module>
  File "e:\python-dev\py3k\lib\test\test_tarfile.py", line 1563, in test_main
  File "e:\python-dev\py3k\lib\shutil.py", line 283, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "e:\python-dev\py3k\lib\shutil.py", line 281, in rmtree
WindowsError: [Error 32] プロセスはファイルにアクセスできません。別のプロセスが
使用中です。: 'E:\\PYTHON~1\\py3k\\@test_5276_tmp\\tmp.tar'

# It says "Process cannot access the file. Another process is using it."

I tried to reproduce this by running test_tarfile alone, but failed.
But I succeeded to do it with following command.
  py3k -m test.regrtest test_capi test_tarfile

(Probably there is timing problem like GC... The reason why I think
so is below)

I think _Stream object left opened after exception occured in (even
after returned from function Tarfile#open) because it lives in stack
frame. Because t._extfileobj is True by default, TarFile object won't close it explicitly.

components: Extension Modules
files: py3k_fix_tarfile.patch
keywords: patch
messages: 115984
nosy: ocean-city
priority: normal
severity: normal
status: open
title: test_tarfile sometimes ends with error "Cannot remoe dir"
versions: Python 3.1, Python 3.2
Added file: http://bugs.python.org/file18815/py3k_fix_tarfile.patch

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list