[python-hdf5storage] 66/152: Fixed a file clean up bug on error.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:24:35 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag 0.1
in repository python-hdf5storage.

commit 54d2b0ffd6fd1435f54409c1eae2e2ae22d1a6a4
Author: Freja Nordsiek <fnordsie at gmail.com>
Date:   Thu Jan 30 21:54:17 2014 -0500

    Fixed a file clean up bug on error.
---
 hdf5storage/__init__.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hdf5storage/__init__.py b/hdf5storage/__init__.py
index b87bea1..0d521f1 100644
--- a/hdf5storage/__init__.py
+++ b/hdf5storage/__init__.py
@@ -916,6 +916,7 @@ def write(data, name='/', filename='data.h5', truncate_existing=False,
     # wrapped in a try block, so that the file can be closed if any
     # errors happen (the error is re-raised).
 
+    f = None
     try:
 
         # If the file doesn't already exist or the option is set to
@@ -956,8 +957,9 @@ def write(data, name='/', filename='data.h5', truncate_existing=False,
         print("Unexpected error:", sys.exc_info()[0])
         raise
     finally:
-        userblock_size = f.userblock_size
-        f.close()
+        if isinstance(f, h5py.File):
+            userblock_size = f.userblock_size
+            f.close()
 
     # If we are doing MATLAB formatting and there is a sufficiently
     # large userblock, write the new userblock. The same sort of error

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-hdf5storage.git



More information about the debian-science-commits mailing list