Project

General

Profile

Actions

Bug #1552

closed

String#strip! raises RuntimeError on Frozen String Despite Making No Changes

Added by runpaint (Run Paint Run Run) almost 15 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2dev (2009-05-28 trunk 23601) [i686-linux]
Backport:
[ruby-core:23659]

Description

=begin
Calling String#strip! on a frozen string raises a RuntimeError even if the string was not changed. String#rstrip! doesn't raise an exception in this scenario. I believe that the latter behaviour is correct; #strip! should only raise a RuntimeError if the string would be changed.

$ rubybleed -ve '"ruby".freeze.strip!'
ruby 1.9.2dev (2009-05-28 trunk 23601) [i686-linux]
-e:1:in strip!': can't modify frozen string (RuntimeError) from -e:1:in '

$ rubybleed -ve '"ruby".freeze.rstrip!'
ruby 1.9.2dev (2009-05-28 trunk 23601) [i686-linux]

1.9.1 behaves the same as 1.9.2. 1.8.7 behaves correctly.
=end

Actions #1

Updated by matz (Yukihiro Matsumoto) almost 15 years ago

  • Status changed from Open to Closed

=begin
changed to the opposite way for consistency.
=end

Actions

Also available in: Atom PDF

Like0
Like0