Project

General

Profile

Bug #2681

some behavior changes of lib/csv.rb between 1.8 and 1.9

Added by mame (Yusuke Endoh) about 10 years ago. Updated almost 9 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2010-01-28 trunk 26458) [i686-linux]
Backport:
[ruby-core:27930]

Description

=begin
Hi jeg2, or anyone who knows the implementation of FasterCSV,

I'm now checking for ruby trunk to pass rubyspec. Are these behavior
changes of lib/csv.rb intended or bug?

1) CSV.generate

$ ruby18 -rcsv -e 'w = CSV.generate("foo18.csv"); w << [1, 2, 3]; w.close'
$ cat foo18.csv
1,2,3

$ ruby19 -rcsv -e 'w = CSV.generate("foo19.csv"); w << [1, 2, 3]; w.close'
/home/mame/work/ruby19/local/lib/ruby/1.9.1/csv.rb:1231:in
generate': no block given (yield) (LocalJumpError)
from -e:1:in
'

There is the comment of csv.rb:

The old CSV's Reader and Writer classes have been dropped.
CSV::generate() is different from the old method.
They mean this change, don't they?

2) CSV.generate_line

$ ruby18 -rcsv -e 'p CSV.generate_line([])'
""

$ ruby19 -rcsv -e 'p CSV.generate_line([])'
"\n"

3) CSV.generate_line (2)

$ ruby18 -rcsv -e 'p CSV::generate_line(["foo", "bar"], ?;)'
"foo;bar"

$ ruby19 -rcsv -e 'p CSV::generate_line(["foo", "bar"], ?;)'
/home/mame/work/ruby19/local/lib/ruby/1.9.1/csv.rb:1249:in merge':
can't convert String into Hash (TypeError)
from /home/mame/work/ruby19/local/lib/ruby/1.9.1/csv.rb:1249:in
generate_line'
from -e:1:in `'

3) CSV.parse

$ ruby18 -rcsv -ve 'p CSV.parse "\nfoo"'
nil], ["foo"

$ ruby19 -rcsv -ve 'p CSV.parse "\nfoo"'
], ["foo"

4) CSV.parse_line

$ ruby18 -rcsv -ve 'p CSV.parse_line ""'
[nil]

$ ruby19 -rcsv -ve 'p CSV.parse_line ""'
nil

5) CSV.parse_line (2)

$ ruby18 -rcsv -ve 'p CSV.parse_line "\nfoo"'
[nil]

$ ruby19 -rcsv -ve 'p CSV.parse_line "\nfoo"'
[]

Thanks,

--
Yusuke ENDOH mame@tsg.ne.jp
=end

Also available in: Atom PDF