Marshall and StringIO objects 
Author Message
 Marshall and StringIO objects

rubyists-

does it not make sense that this should work?

~ > irb -r stringio
irb(main):001:0> Marshal.dump 'foobar', StringIO.new
TypeError: instance of IO needed
        from (irb):1:in `dump'
        from (irb):1

-a
--
  ====================================
  | Ara Howard
  | NOAA Forecast Systems Laboratory
  | Information and Technology Services
  | Data Systems Group
  | R/FST 325 Broadway
  | Boulder, CO 80305-3328

  | Phone:  303-497-7238
  | Fax:    303-497-7259
  | ~ > ruby -e 'p % ^) .intern'
  ====================================



Wed, 16 Nov 2005 09:09:00 GMT  
 Marshall and StringIO objects

Quote:

> does it not make sense that this should work?

> ~ > irb -r stringio
> irb(main):001:0> Marshal.dump 'foobar', StringIO.new
> TypeError: instance of IO needed
>         from (irb):1:in `dump'
>         from (irb):1

C:\>irb -r stringio
irb(main):001:0> sio = Marshal.dump('foobar',StringIO.new)
=> #<StringIO:0x27c7a10>
irb(main):002:0> Marshal.load(sio)
EOFError: End of file reached
        from (irb):2:in `load'
        from (irb):2
irb(main):003:0> quit

C:\>irb -v
irb 0.9(02/07/03)

C:\>ruby -v
ruby 1.8.0 (2003-05-26) [i386-mswin32]



Wed, 16 Nov 2005 09:39:56 GMT  
 Marshall and StringIO objects

Quote:

> C:\>irb -r stringio
> irb(main):001:0> sio = Marshal.dump('foobar',StringIO.new)
> => #<StringIO:0x27c7a10>
> irb(main):002:0> Marshal.load(sio)
> EOFError: End of file reached
>         from (irb):2:in `load'
>         from (irb):2
> irb(main):003:0> quit

Oops ... sorry, copied the wrong example. Here is the correct one:

C:\>irb -r stringio
irb(main):001:0> sio = Marshal.dump('foobar',StringIO.new)
=> #<StringIO:0x27c7a10>
irb(main):002:0> p sio
#<StringIO:0x27c7a10>
=> nil
irb(main):003:0> sio.rewind
=> 0
irb(main):004:0> puts Marshal.load(sio)
foobar
=> nil
irb(main):005:0> quit



Wed, 16 Nov 2005 09:44:39 GMT  
 Marshall and StringIO objects

Quote:

> Oops ... sorry, copied the wrong example. Here is the correct one:

> C:\>irb -r stringio
> irb(main):001:0> sio = Marshal.dump('foobar',StringIO.new)
> => #<StringIO:0x27c7a10>
> irb(main):002:0> p sio
> #<StringIO:0x27c7a10>
> => nil
> irb(main):003:0> sio.rewind
> => 0
> irb(main):004:0> puts Marshal.load(sio)
> foobar
> => nil
> irb(main):005:0> quit

ahhh...  i tried 1.6 w/shim, not 1.8.  thanks!

-a
--
  ====================================
  | Ara Howard
  | NOAA Forecast Systems Laboratory
  | Information and Technology Services
  | Data Systems Group
  | R/FST 325 Broadway
  | Boulder, CO 80305-3328

  | Phone:  303-497-7238
  | Fax:    303-497-7259
  | ~ > ruby -e 'p % ^) .intern'
  ====================================



Wed, 16 Nov 2005 20:15:11 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Why Tcl "extensions suck" (Marshall/Ousterhout)

2. Why Tcl "extensions suck" (Marshall/Ousterhout)

3. Why Tcl "extensions suck" (Marshall/Ousterhout)

4. Strange cgi.rb <--> StringIO problem

5. StringIO (was: Namespaces (was: protected program in a program))

6. stringio bug

7. stringIO extension?

8. Problem with execfile and StringIO

9. XMLGenerator / StringIO / ordinal not in range

10. StringIO vs array.tofile() ?

11. StringIO readline() bug??

12. StringIO and Berkley DB

 

 
Powered by phpBB® Forum Software