From: colin@... Date: 2015-12-05T16:20:48+00:00 Subject: [ruby-core:71846] [Ruby trunk - Bug #11759] URI breaks with frozen strings Issue #11759 has been updated by Colin Kelley. File 11759-rev2.patch added > Outputs: > 480 > 416 > 416 That is more significant than I thought. `''.dup` wins. > No, we shouldn't worry about performance with older versions of Ruby > with the stdlib. Good to have that confirmed. Then we should definitely leave the magic comment at the top for these reasons: a) It documents which files have been visited in the process of converting to immutable string literals. b) It allows us to immediately remove the clutter of `.freeze` at the end of string literals I've attached an updated patch with the above changes. > There may be code out in the wild which relies on "path" being mutable. I don't think we have to support that. Callers should not expect to be able to mutate object internals retrieved by accessors. If they try and a "can't modify frozen String" exception is raised, they can fix _their_ code to `dup` the value. ---------------------------------------- Bug #11759: URI breaks with frozen strings https://bugs.ruby-lang.org/issues/11759#change-55252 * Author: Mike Perham * Status: Open * Priority: Normal * Assignee: * ruby -v: 2.3.0-preview1 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- It appears URI uses String mutation and breaks frozen string mode. ~~~ $ RUBYOPT="--enable-frozen-string-literal" bundle exec rake /Users/mike/.rubies/ruby-2.3.0-preview1/lib/ruby/2.3.0/uri/generic.rb:1344:in `to_s': can't modify frozen String (RuntimeError) /Users/mike/.gem/ruby/2.3.0/gems/bundler-1.10.6/lib/bundler/source/rubygems.rb:257:in `normalize_uri' /Users/mike/.gem/ruby/2.3.0/gems/bundler-1.10.6/lib/bundler/source/rubygems.rb:198:in `add_remote' /Users/mike/.gem/ruby/2.3.0/gems/bundler-1.10.6/lib/bundler/source/rubygems.rb:25:in `block in initialize' /Users/mike/.gem/ruby/2.3.0/gems/bundler-1.10.6/lib/bundler/source/rubygems.rb:25:in `reverse_each' /Users/mike/.gem/ruby/2.3.0/gems/bundler-1.10.6/lib/bundler/source/rubygems.rb:25:in `initialize' ~~~ ---Files-------------------------------- 0001-Do-not-mutate-strings-in-URI-to_s.patch (1.76 KB) 11759.patch (610 Bytes) 11759-rev2.patch (3.21 KB) -- https://bugs.ruby-lang.org/