[Python-checkins] cpython (3.3): Issue #20244: Fixed possible file leaks when unexpected error raised in

serhiy.storchaka python-checkins at python.org
Sat Jan 18 15:31:47 CET 2014


http://hg.python.org/cpython/rev/05d186a1a367
changeset:   88551:05d186a1a367
branch:      3.3
parent:      88549:2f3b47b63f91
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Sat Jan 18 16:28:08 2014 +0200
summary:
  Issue #20244: Fixed possible file leaks when unexpected error raised in
tarfile open functions.

files:
  Lib/tarfile.py |  6 ++++++
  1 files changed, 6 insertions(+), 0 deletions(-)


diff --git a/Lib/tarfile.py b/Lib/tarfile.py
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1671,6 +1671,9 @@
             if mode == 'r':
                 raise ReadError("not a bzip2 file")
             raise
+        except:
+            fileobj.close()
+            raise
         t._extfileobj = False
         return t
 
@@ -1696,6 +1699,9 @@
             if mode == 'r':
                 raise ReadError("not an lzma file")
             raise
+        except:
+            fileobj.close()
+            raise
         t._extfileobj = False
         return t
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list