Project

General

Profile

Actions

Bug #1510

closed

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

Added by marcandre (Marc-Andre Lafortune) almost 15 years ago. Updated almost 13 years ago.

Status:
Closed
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:
["", #<C:0x2c62a8>, "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
Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 15 years ago

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

=begin
Applied in changeset r23562.
=end

Actions #2

Updated by marcandre (Marc-Andre Lafortune) almost 15 years ago

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

Actions

Also available in: Atom PDF

Like0
Like0Like0