[SciPy-user] scipy.io.read_array exception on Windows (bug?)

Robert Kern robert.kern@gmail....
Fri Apr 11 16:59:39 CDT 2008


On Fri, Apr 11, 2008 at 3:56 PM, Marek Wojciechowski <mwojc@p.lodz.pl> wrote:
> Hi!
>
>  On Windows, Python 2.5 and scipy-0.6.0 when i call
>     data = read_array( file, **kwargs )
>  and file argument is the fileobject the following exception occurs:
>
>  Traceback (most recent call last):
>    File "C:\Python25\Lib\site-packages\ffnet\ffnet.py", line 851, in readdata
>      data = read_array( file, **kwargs )
>    File "C:\Python25\Lib\site-packages\scipy\io\array_import.py", line 364, in
>  read_array
>      ascii_object = ascii_stream(fileobject, lines=lines, comment=comment,
>  linesep=linesep)
>    File "C:\Python25\Lib\site-packages\scipy\io\array_import.py", line 141, in
>  __init__
>      self.file = get_open_file(fileobject, mode='r')
>    File "C:\Python25\Lib\site-packages\scipy\io\array_import.py", line 97, in
>  get_open_file
>      fileobject = os.path.expanduser(fileobject)
>    File "C:\Python25\lib\ntpath.py", line 350, in expanduser
>      if path[:1] != '~':
>  TypeError: 'file' object is unsubscriptable
>
>  However if i use a filename string as the argument everything works fine. Is
>  this a known problem?

It is now! We do catch AttributeError, but it appears that a TypeError
is also possible, at least in some versions of Python. I have fixed
this in r4133.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco


More information about the SciPy-user mailing list