Bug #13149
Updated by koshigoe (Masataka SUZUKI) almost 8 years ago
Ruby 2.4.0 から、指定文字数未満で例外が出る事も、指定文字数以上で例外が出ない事もあります。 以下、指定文字数未満で例外が出るケース。 ~~~ <pre><code class="ruby"> require 'csv' CSV.new(DATA, field_size_limit: 4).each { |x| p x } __END__ "a","b" " 2 ","" ~~~ </code></pre> ~~~ <pre> $ ruby test.rb ["a", "b"] ~/.rbenv/versions/2.4.0/lib/ruby/2.4.0/csv.rb:1931:in `block in shift': Field size exceeded on line 2. (CSV::MalformedCSVError) from ~/.rbenv/versions/2.4.0/lib/ruby/2.4.0/csv.rb:1828:in `loop' from ~/.rbenv/versions/2.4.0/lib/ruby/2.4.0/csv.rb:1828:in `shift' from ~/.rbenv/versions/2.4.0/lib/ruby/2.4.0/csv.rb:1770:in `each' from test.rb:3:in `<main>' ~~~ </pre> 以下、指定文字数以上で例外が出ないケース。 ~~~ <pre><code class="ruby"> require 'csv' CSV.new(DATA, field_size_limit: 5).each { |x| p x } __END__ "a","b" " 2345 ","" ~~~ </code></pre> ~~~ <pre> $ ruby test.rb ["a", "b"] ["\n2345\n", ""] ~~~ </pre>