From: Charlie Somerville Date: 2012-12-07T21:07:00+09:00 Subject: [ruby-core:50657] Re: [ruby-trunk - Bug #7528] CSV.== fails to check object type --14dae93405fd6fa80704d041fa3d Content-Type: text/plain; charset=UTF-8 =begin It would probably be better to perform an (({is_a?})) check rather than checking the class of the other object. =end On Dec 7, 2012 10:56 PM, "SteveW (Stephen Wattam)" wrote: > > Issue #7528 has been updated by SteveW (Stephen Wattam). > > > This seems to fix it: > > 478c478,479 > < @row == other.row > --- > > return @row == other.row if other.class == CSV::Row > > @row == other > > ---------------------------------------- > Bug #7528: CSV.== fails to check object type > https://bugs.ruby-lang.org/issues/7528#change-34502 > > Author: SteveW (Stephen Wattam) > Status: Open > Priority: Normal > Assignee: > Category: > Target version: > ruby -v: ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux] > > > CSV::Row's equality method presumes it is comparing another CSV::Row. It > fails when the object to be compared doesn't support the 'row' method: > > /usr/lib/ruby/1.9.1/csv.rb:478:in `==': undefined method `row' for > nil:NilClass (NoMethodError) > from test.rb:7:in `
' > > > > -- > http://bugs.ruby-lang.org/ > > --14dae93405fd6fa80704d041fa3d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

=3Dbegin
It would probably be better to perform an (({is_a?})) check rather than che= cking the class of the other object.
=3Dend

On Dec 7, 2012 10:56 PM, "SteveW (Stephen W= attam)" <stephenwattam@g= mail.com> wrote:

Issue #7528 has been updated by SteveW (Stephen Wattam).


This seems to fix it:

478c478,479
< =C2=A0 =C2=A0 =C2=A0 @row =3D=3D other.row
---
> =C2=A0 =C2=A0 =C2=A0 return @row =3D=3D other.row if other.class =3D= =3D CSV::Row
> =C2=A0 =C2=A0 =C2=A0 @row =3D=3D other

----------------------------------------
Bug #7528: CSV.=3D=3D fails to check object type
https://bugs.ruby-lang.org/issues/7528#change-34502

Author: SteveW (Stephen Wattam)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]


CSV::Row's equality method presumes it is comparing another CSV::Row. = =C2=A0It fails when the object to be compared doesn't support the '= row' method:

/usr/lib/ruby/1.9.1/csv.rb:478:in `=3D=3D': undefined method `row' = for nil:NilClass (NoMethodError)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 from test.rb:7:in `<main>'



--
http://bugs.ruby-l= ang.org/

--14dae93405fd6fa80704d041fa3d--