Project

General

Profile

Actions

Bug #2681

closed

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

Added by mame (Yusuke Endoh) almost 15 years ago. Updated over 13 years ago.

Status:
Rejected
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?

  1. CSV.generate_line

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

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

  1. 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 `'

  1. CSV.parse

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

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

  1. CSV.parse_line

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

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

  1. CSV.parse_line (2)

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

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

Thanks,

--
Yusuke ENDOH
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0