scipy.io.read_array exception on Windows (bug?)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

scipy.io.read_array exception on Windows (bug?)

Marek Wojciechowski-2
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? I suppose both fileobject and filename arguments should
work (as for example on my Linux, Python 2.4 and scipy-0.6.0)

Greetings
--
Marek Wojciechowski
_______________________________________________
SciPy-user mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: scipy.io.read_array exception on Windows (bug?)

Robert Kern-2
On Fri, Apr 11, 2008 at 3:56 PM, Marek Wojciechowski <[hidden email]> 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
_______________________________________________
SciPy-user mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/scipy-user