[Scipy-svn] r3180 - trunk/Lib/io
scipy-svn@scip...
scipy-svn@scip...
Mon Jul 23 01:57:56 CDT 2007
Author: rkern
Date: 2007-07-23 01:57:45 -0500 (Mon, 23 Jul 2007)
New Revision: 3180
Modified:
trunk/Lib/io/array_import.py
Log:
Don't close the file object if we were given a real file object rather than a filename.
Modified: trunk/Lib/io/array_import.py
===================================================================
--- trunk/Lib/io/array_import.py 2007-07-22 02:43:59 UTC (rev 3179)
+++ trunk/Lib/io/array_import.py 2007-07-23 06:57:45 UTC (rev 3180)
@@ -139,6 +139,7 @@
self.comment = comment
self.lencomment = len(comment)
self.file = get_open_file(fileobject, mode='r')
+ self.should_close_file = not (self.file is fileobject)
self._pos = self.file.tell()
self._lineindex = 0
if self.linelist[-1] < 0:
@@ -166,7 +167,7 @@
return lines[:-1]
def __del__(self):
- if hasattr(self.file,'close'):
+ if hasattr(self.file,'close') and self.should_close_file:
self.file.close()
def __getitem__(self, item):
More information about the Scipy-svn
mailing list