[#82311] [Ruby trunk Bug#13794] Infinite loop of sched_yield — charlie@...
Issue #13794 has been reported by catphish (Charlie Smurthwaite).
4 messages
2017/08/09
[#82518] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — mame@...
Issue #13618 has been updated by mame (Yusuke Endoh).
5 messages
2017/08/30
[#82552] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wong <normalperson@...>
2017/08/31
[email protected] wrote:
[#82756] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wrong <normalperson@...>
2017/09/12
Eric Wrong <[email protected]> wrote:
[ruby-core:82441] [Ruby trunk Bug#11126] CSV field converters doesn't attempt to convert nil value.
From:
hsbt@...
Date:
2017-08-22 06:42:06 UTC
List:
ruby-core #82441
Issue #11126 has been updated by hsbt (Hiroshi SHIBATA).
Assignee changed from JEG2 (James Gray) to hsbt (Hiroshi SHIBATA)
----------------------------------------
Bug #11126: CSV field converters doesn't attempt to convert nil value.
https://bugs.ruby-lang.org/issues/11126#change-66252
* Author: hanachin (Seiei Miyagi)
* Status: Assigned
* Priority: Normal
* Assignee: hsbt (Hiroshi SHIBATA)
* Target version:
* ruby -v: ruby 2.3.0dev (2015-05-05 trunk 50430) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
following code behaves differently between ruby 2.2.2/trunk and 2.1.5.
```ruby
require 'csv'
converter = lambda { |field| field.nil? }
p CSV.parse_line('nil,', converters: converter)
```
```console
$ ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
$ ruby csv.rb
[false, true]
```
```console
$ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
$ ruby csv.rb
[false, nil]
```
CSV header conversion changed at r45497 but it also affects field conversion.
https://github.com/ruby/ruby/pull/575
I attached a patch to revert the field conversion behavior to >= 2.1.
```patch
diff --git lib/csv.rb lib/csv.rb
index 54b820d..2edaf5a 100644
--- lib/csv.rb
+++ lib/csv.rb
@@ -2188,7 +2188,7 @@ def convert_fields(fields, headers = false)
fields.map.with_index do |field, index|
converters.each do |converter|
- break if field.nil?
+ break if headers && field.nil?
field = if converter.arity == 1 # straight field converter
converter[field]
else # FieldInfo converter
diff --git test/csv/test_data_converters.rb test/csv/test_data_converters.rb
index 89b6dd1..3a6f46f 100755
--- test/csv/test_data_converters.rb
+++ test/csv/test_data_converters.rb
@@ -175,6 +175,15 @@ def test_convert_with_custom_code_using_field_info_header
@parser.shift.fields )
end
+ def test_custom_converter_with_blank_field
+ converter = lambda { |field| field.nil? }
+ row = nil
+ assert_nothing_raised(Exception) do
+ row = CSV.parse_line('nil,', converters: converter)
+ end
+ assert_equal([false, true], row);
+ end
+
def test_shortcut_interface
assert_equal( ["Numbers", ":integer", 1, ":float", 3.015],
CSV.parse_line(@data, converters: :numeric) )
```
---Files--------------------------------
csv.patch (1.18 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>