Project

General

Profile

Bug #1510

[patch] String#partition can return wrong result or crash

Added by marcandre (Marc-Andre Lafortune) about 10 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2dev (2009-05-24 trunk 23557) [i386-darwin9.7.0]
Backport:
[ruby-core:23540]

Description

=begin
The attached patch fixes a problem that occurs when the argument of String#partition needs to be converted using :to_str.

E.g:

class C
def to_str
"foo"
end
end
p "foo-bar".partition(C.new)

Before patch:
["", #, "foo-bar"]

After patch:
["", "foo", "-bar"]

RubySpecs has been updated. Without the version guard, it crashes Ruby.
=end


Files

partition.patch (332 Bytes) partition.patch marcandre (Marc-Andre Lafortune), 05/25/2009 07:36 AM

History

#1

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r23562.
=end

#2

Updated by marcandre (Marc-Andre Lafortune) about 10 years ago

=begin
Thanks, that was really quick!
I just noticed that rpartition has the same problem...
=end

Also available in: Atom PDF