[MacRuby] #146: Crash While Using CSV
#146: Crash While Using CSV --------------------------------+------------------------------------------- Reporter: ted.reed@gmail.com | Owner: lsansonetti@apple.com Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: --------------------------------+------------------------------------------- I've encountered a crash in MacRuby. The following code works fine on Leopard's standard Ruby, but causes MacRuby to die: {{{ require 'csv' filename = "/Users/treed/Documents/test.fr" friends = [] class Friend attr_accessor :first_name, :last_name, :phone_number, :email_address end reader = CSV.open(filename, 'r') reader.each do |row| # All of this inside the loop can be commented out and the outcome is the same. friend = Friend.new friend.first_name = (row[0] || "") friend.last_name = (row[1] || "") friend.phone_number = (row[2] || "") friend.email_address = (row[3] || "") friends << friend end reader.close }}} It seems like it's the call to ''reader.each'' that's crashing. ''reader.shift'' works fine, but even a blank loop with ''reader.each'' seems to crash. If more info is needed, let me know and I can try to provide. (Yeah, I was trying to implement the suggestions at the end of the ADC tutorial. BTW, nice work so far, guys. I'm really impressed with MacRuby.) -- Ticket URL: <http://www.macruby.org/trac/ticket/146> MacRuby <http://macruby.org/>
#146: Crash While Using CSV --------------------------------+------------------------------------------- Reporter: ted.reed@gmail.com | Owner: lsansonetti@apple.com Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Resolution: Keywords: | --------------------------------+------------------------------------------- Comment(by ted.reed@gmail.com): Wait, strike that. I just did additional testing and it looks like ''reader.shift'' isn't fine as I thought. It's fine for the first four times, but then when there's no more data to be read, it crashes. Leopard's standard Ruby just returns an empty array. -- Ticket URL: <http://www.macruby.org/trac/ticket/146#comment:1> MacRuby <http://macruby.org/>
#146: Crash While Using CSV --------------------------------+------------------------------------------- Reporter: ted.reed@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Resolution: fixed Keywords: | --------------------------------+------------------------------------------- Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.5 Comment: Looks like this is fixed in trunk. {{{ $ cat t.rb require 'csv' filename = "t.csv" friends = [] class Friend attr_accessor :first_name, :last_name, :phone_number, :email_address end reader = CSV.open(filename, 'r') reader.each do |row| # All of this inside the loop can be commented out and the outcome is the same. friend = Friend.new friend.first_name = (row[0] || "") friend.last_name = (row[1] || "") friend.phone_number = (row[2] || "") friend.email_address = (row[3] || "") friends << friend end reader.close p friends }}} {{{ $ ./miniruby t.rb [##-<Friend:0x20031abe0 @first_name="John", @last_name="Smith", @phone_number="", @email_address="">, ##-<Friend:0x20031e7e0 @first_name="John", @last_name="Smith", @phone_number="", @email_address="">, ##-<Friend:0x20031fd80 @first_name="John", @last_name="Smith", @phone_number="555-1212", @email_address="">, ##-<Friend:0x2003210c0 @first_name="John", @last_name="Thompson", @phone_number="", @email_address="">] $ ruby19 t.rb [#<Friend:0x00000100a68438 @first_name="John", @last_name="Smith", @phone_number="", @email_address="">, #<Friend:0x00000100a67e48 @first_name="John", @last_name="Smith", @phone_number="", @email_address="">, #<Friend:0x00000100a67808 @first_name="John", @last_name="Smith", @phone_number="555-1212", @email_address="">, #<Friend:0x00000100a67240 @first_name="John", @last_name="Thompson", @phone_number="", @email_address="">] }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/146#comment:2> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby