[issue7232] Support of 'with' statement fo TarFile class

Lars Gustäbel report at bugs.python.org
Sun Feb 28 22:05:27 CET 2010


Lars Gustäbel <lars at gustaebel.de> added the comment:

I found an issue that needs to be addressed: if there is an error while the TarFile object is opened for writing, we cannot simply call TarFile.close() in the __exit__() method. close() would try to finalize the archive, i.e. write two zero end-of-archive blocks and a number of padding blocks.

I changed __exit__() to call close() only if everything went fine. If there was an exception only the most basic cleanup is done.

I added more tests and adapted the docs.

----------
Added file: http://bugs.python.org/file16401/issue7232.9.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7232>
_______________________________________


More information about the Python-bugs-list mailing list