[Scipy-svn] r4133 - in trunk/scipy/io: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Fri Apr 11 17:56:59 EDT 2008
Author: rkern
Date: 2008-04-11 16:56:58 -0500 (Fri, 11 Apr 2008)
New Revision: 4133
Modified:
trunk/scipy/io/array_import.py
trunk/scipy/io/tests/test_array_import.py
Log:
A TypeError is also possible when using a filelike object with os.path.expanduser().
Modified: trunk/scipy/io/array_import.py
===================================================================
--- trunk/scipy/io/array_import.py 2008-04-11 02:33:53 UTC (rev 4132)
+++ trunk/scipy/io/array_import.py 2008-04-11 21:56:58 UTC (rev 4133)
@@ -109,7 +109,7 @@
if type(details) == type(()):
details = details + (fileobject,)
raise IOError, details
- except AttributeError:
+ except (AttributeError, TypeError):
# it is assumed that the fileobject is a python
# file object if it can not be used in os.path.expanduser
file = fileobject
Modified: trunk/scipy/io/tests/test_array_import.py
===================================================================
--- trunk/scipy/io/tests/test_array_import.py 2008-04-11 02:33:53 UTC (rev 4132)
+++ trunk/scipy/io/tests/test_array_import.py 2008-04-11 21:56:58 UTC (rev 4133)
@@ -1,5 +1,3 @@
-## Automatically adapted for scipy Oct 19, 2005 by convertcode.py
-
#!/usr/bin/env python
# This python script tests the numpyio module.
@@ -9,6 +7,7 @@
from scipy.testing import *
import scipy.io as io
from scipy.io import numpyio
+from scipy.io import array_import
import numpy.oldnumeric as N
import tempfile
@@ -57,5 +56,12 @@
assert_array_equal(a,b)
os.remove(fname)
+class TestRegression(TestCase):
+ def test_get_open_file_works_with_filelike_objects(self):
+ f = tempfile.TemporaryFile()
+ f2 = array_import.get_open_file(f)
+ assert f2 is f
+ f.close()
+
if __name__ == "__main__":
nose.run(argv=['', __file__])
More information about the Scipy-svn
mailing list