[#74190] [Ruby trunk Feature#12134] Comparison between `true` and `false` — duerst@...
SXNzdWUgIzEyMTM0IGhhcyBiZWVuIHVwZGF0ZWQgYnkgTWFydGluIETDvHJzdC4KCgpUc3V5b3No
3 messages
2016/03/07
[#74269] Type systems for Ruby — Rob Blanco <ml@...>
Dear ruby-core,
5 messages
2016/03/10
[#74395] [Ruby trunk Feature#12142] Hash tables with open addressing — shyouhei@...
Issue #12142 has been updated by Shyouhei Urabe.
3 messages
2016/03/17
[ruby-core:74509] [Ruby trunk Bug#12100][Rejected] CSV converters fail when using single arg proc
From:
usa@...
Date:
2016-03-24 07:16:23 UTC
List:
ruby-core #74509
Issue #12100 has been updated by Usaku NAKAMURA.
Status changed from Closed to Rejected
----------------------------------------
Bug #12100: CSV converters fail when using single arg proc
https://bugs.ruby-lang.org/issues/12100#change-57630
* Author: Matthew Daubert
* Status: Rejected
* Priority: Normal
* Assignee:
* ruby -v: all versions 2.0, 2.1, 2.2, 2.3, trunk
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
CSV#parse (and others) throw an ArgumentError when passing a single argument Proc as a converter because of a performance optimization check that assumes Proc#arity is always positive. Lambdas with one argument work fine as do Procs and lambdas with two arguments. The documentation suggests to me that either should work. Supporting the Proc variant is trivial and allows to_proc and to_proc shortcut syntax to be used eliminating the surprising behavior and uninformative error message. Illustration of the problem is below and a patch with tests is attached. I'm also creating a PR on Github because I think this is a minor enough change to be merged quickly. Thank you.
~~~
require 'csv'
puts CSV.parse(" foo , bar ", converters: -> f { f.strip }).inspect
puts CSV.parse(" foo , bar ", converters: :strip.to_proc).inspect
# Without patch this outputs:
# [["foo", "bar"]]
# /home/mdaubert/.rbenv/versions/2.3.0/lib/ruby/2.3.0/csv.rb:2205:in `strip': wrong number of arguments (given 1, expected 0) (ArgumentError)
# With patch this outputs:
# [["foo", "bar"]]
# [["foo", "bar"]]
~~~
---Files--------------------------------
fix_csv_converter_single_arg_proc.patch (1.78 KB)
--
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>