ruby-changes:47526
From: hsbt <ko1@a...>
Date: Tue, 22 Aug 2017 15:41:04 +0900 (JST)
Subject: [ruby-changes:47526] hsbt:r59642 (trunk): Gracefully handle CSV IO when file descriptor closed.
hsbt 2017-08-22 15:40:59 +0900 (Tue, 22 Aug 2017) New Revision: 59642 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59642 Log: Gracefully handle CSV IO when file descriptor closed. [Bug #10504][ruby-core:66240] Modified files: trunk/lib/csv.rb trunk/test/csv/test_interface.rb Index: test/csv/test_interface.rb =================================================================== --- test/csv/test_interface.rb (revision 59641) +++ test/csv/test_interface.rb (revision 59642) @@ -137,6 +137,14 @@ class TestCSV::Interface < TestCSV https://github.com/ruby/ruby/blob/trunk/test/csv/test_interface.rb#L137 end end + def test_open_handles_prematurely_closed_file_descriptor_gracefully + assert_nothing_raised(Exception) do + CSV.open(@path) do |csv| + csv.close + end + end + end + ### Test Write Interface ### def test_generate Index: lib/csv.rb =================================================================== --- lib/csv.rb (revision 59641) +++ lib/csv.rb (revision 59642) @@ -1291,7 +1291,7 @@ class CSV https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L1291 begin yield csv ensure - csv.close + csv.closed? || csv.close end else csv -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/