Issue #17430 has been reported by Soilent (Konstantin x).

----------------------------------------
Bug #17430: CSV: NoMethodError when the write_nil_value or write_empty_value options are used
https://bugs.ruby-lang.org/issues/17430

* Author: Soilent (Konstantin x)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
CSV.generate_line throws an exception when I specify `write_nil_value` or `write_nil_value`.

```
> CSV.generate_line [1,nil,3]
=> "1,,3\n"
> CSV.generate_line [1,nil,3], write_nil_value: 'x'
Traceback (most recent call last):
       12: from /usr/bin/irb:23:in `<main>'
       11: from /usr/bin/irb:23:in `load'
       10: from /usr/lib/ruby/gems/2.7.0/gems/irb-1.2.7/exe/irb:11:in `<top (required)>'
        9: from (irb):3
        8: from (irb):4:in `rescue in irb_binding'
        7: from /usr/lib/ruby/2.7.0/csv.rb:569:in `generate_line'
        6: from /usr/lib/ruby/2.7.0/csv.rb:1230:in `<<'
        5: from /usr/lib/ruby/2.7.0/csv/writer.rb:44:in `<<'
        4: from /usr/lib/ruby/2.7.0/csv/fields_converter.rb:50:in `convert'
        3: from /usr/lib/ruby/2.7.0/csv/fields_converter.rb:50:in `with_index'
        2: from /usr/lib/ruby/2.7.0/csv/fields_converter.rb:50:in `collect'
        1: from /usr/lib/ruby/2.7.0/csv/fields_converter.rb:53:in `block in convert'
NoMethodError (undefined method `empty?' for 1:Integer)
> CSV.generate_line [1,nil,3], write_empty_value: 'x'
NoMethodError (undefined method `empty?' for 1:Integer)
```



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>