From: nobu@... Date: 2016-05-26T06:54:30+00:00 Subject: [ruby-core:75728] [Ruby trunk Bug#12422][Assigned] CSV.Table.== fails to check object type Issue #12422 has been updated by Nobuyoshi Nakada. Description updated Status changed from Open to Assigned Assignee set to James Gray Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED ---------------------------------------- Bug #12422: CSV.Table.== fails to check object type https://bugs.ruby-lang.org/issues/12422#change-58856 * Author: Felix Kenton * Status: Assigned * Priority: Normal * Assignee: James Gray * ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] * Backport: 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED ---------------------------------------- `CSV::Table`'s equality method presumes it is comparing another `CSV::Table`. It fails when the object to be compared doesn't support the `table` method. This is more or less the same issue as reported and fixed in Bug #7528 (https://bugs.ruby-lang.org/issues/7528). ### Test Case ```ruby require 'csv' CSV.parse("test", headers: true) == nil # => NoMethodError: undefined method `table' for nil:NilClass ``` ### Suggested Patch Following the implementation used in `CSV::Row`, a suggested patch would be: ```ruby def ==(other) return @table == other.table if other.is_a? CSV::Table @table == other end ``` -- https://bugs.ruby-lang.org/ Unsubscribe: