[Scipy-svn] r2326 - trunk/Lib/io
scipy-svn at scipy.org
scipy-svn at scipy.org
Tue Nov 21 16:06:56 CST 2006
Author: matthew.brett at gmail.com
Date: 2006-11-21 16:06:52 -0600 (Tue, 21 Nov 2006)
New Revision: 2326
Modified:
trunk/Lib/io/mio.py
Log:
Fix bugs in file stream handling in savemat
Modified: trunk/Lib/io/mio.py
===================================================================
--- trunk/Lib/io/mio.py 2006-11-21 18:33:56 UTC (rev 2325)
+++ trunk/Lib/io/mio.py 2006-11-21 22:06:52 UTC (rev 2326)
@@ -108,7 +108,8 @@
@appendmat - if true, appends '.mat' extension to filename, if not present
"""
- if isinstance(file_name, basestring):
+ file_is_string = isinstance(file_name, basestring)
+ if file_is_string:
if appendmat and file_name[-4:] != ".mat":
file_name = file_name + ".mat"
file_stream = open(file_name, 'wb')
@@ -117,9 +118,10 @@
file_name.write('')
except AttributeError:
raise IOError, 'Writer needs file name or writeable file-like object'
- byte_stream = file_name
+ file_stream = file_name
MW = MatFile4Writer(file_stream)
MW.put_variables(mdict)
- file_stream.close()
+ if file_is_string:
+ file_stream.close()
More information about the Scipy-svn
mailing list