http://codereview.appspot.com/2759042/diff/1/Lib/tarfile.py File Lib/tarfile.py (right): http://codereview.appspot.com/2759042/diff/1/Lib/tarfile.py#newcode1811 Lib/tarfile.py:1811: gzip.GzipFile(name, mode, compresslevel, fileobj), Make this 'finally' and rop the 'raise' below http://codereview.appspot.com/2759042/diff/1/Lib/test/test_tarfile.py File Lib/test/test_tarfile.py (right): http://codereview.appspot.com/2759042/diff/1/Lib/test/test_tarfile.py#newcode55 Lib/test/test_tarfile.py:55: data = fobj.read() Any reason why you are using a try/finally instead of a context manager? Same goes for all the other places in this file where you don't use a context manager. http://codereview.appspot.com/2759042/diff/1/Lib/test/test_tarfile.py#newcode152 Lib/test/test_tarfile.py:152: If the assertEqual fails these files won't be closed. Better to put them in a nexted context manager.
http://codereview.appspot.com/2759042/diff/1/Lib/tarfile.py File Lib/tarfile.py (right): http://codereview.appspot.com/2759042/diff/1/Lib/tarfile.py#newcode1811 Lib/tarfile.py:1811: gzip.GzipFile(name, mode, compresslevel, fileobj), On 2010/10/29 23:38:39, brett.cannon wrote: > Make this 'finally' and rop the 'raise' below It would be wrong. The file must only be closed on error; on success, it is stored on the instance and used later on (hence the "_extfileobj" attribute as well). http://codereview.appspot.com/2759042/diff/1/Lib/test/test_tarfile.py File Lib/test/test_tarfile.py (right): http://codereview.appspot.com/2759042/diff/1/Lib/test/test_tarfile.py#newcode55 Lib/test/test_tarfile.py:55: data = fobj.read() On 2010/10/29 23:38:39, brett.cannon wrote: > Any reason why you are using a try/finally instead of a context manager? Same > goes for all the other places in this file where you don't use a context > manager. Because that file-like object doesn't support the context manager (which could be the subject of a separate issue, I suppose). http://codereview.appspot.com/2759042/diff/1/Lib/test/test_tarfile.py#newcode152 Lib/test/test_tarfile.py:152: On 2010/10/29 23:38:39, brett.cannon wrote: > If the assertEqual fails these files won't be closed. Better to put them in a > nexted context manager. Ok, will do.