ruby-changes:34042
From: zzak <ko1@a...>
Date: Mon, 26 May 2014 01:41:48 +0900 (JST)
Subject: [ruby-changes:34042] zzak:r46123 (trunk): * lib/csv.rb: Reject nil as data source for CSV.new, patch by @Peeja.
zzak 2014-05-26 01:41:40 +0900 (Mon, 26 May 2014) New Revision: 46123 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=46123 Log: * lib/csv.rb: Reject nil as data source for CSV.new, patch by @Peeja. [Fixes GH-580] https://github.com/ruby/ruby/pull/580 Modified files: trunk/ChangeLog trunk/lib/csv.rb trunk/test/csv/test_interface.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 46122) +++ ChangeLog (revision 46123) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon May 26 01:39:02 2014 Zachary Scott <e@z...> + + * lib/csv.rb: Reject nil as data source for CSV.new, patch by @Peeja. + [Fixes GH-580] https://github.com/ruby/ruby/pull/580 + Mon May 26 01:07:51 2014 Tanaka Akira <akr@f...> * test/lib/minitest/unit.rb: Show leaked threads and tempfiles Index: lib/csv.rb =================================================================== --- lib/csv.rb (revision 46122) +++ lib/csv.rb (revision 46123) @@ -1484,6 +1484,10 @@ class CSV https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L1484 # so be sure to set what you want here. # def initialize(data, options = Hash.new) + if data.nil? + raise ArgumentError.new("Cannot parse nil as CSV") + end + # build the options for this read/write options = DEFAULT_OPTIONS.merge(options) Index: test/csv/test_interface.rb =================================================================== --- test/csv/test_interface.rb (revision 46122) +++ test/csv/test_interface.rb (revision 46123) @@ -130,6 +130,12 @@ class TestCSV::Interface < TestCSV https://github.com/ruby/ruby/blob/trunk/test/csv/test_interface.rb#L130 end end + def test_nil_is_not_acceptable + assert_raise_with_message ArgumentError, "Cannot parse nil as CSV" do + CSV.new(nil) + end + end + ### Test Write Interface ### def test_generate -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/