ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: matz@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:71879] [Ruby trunk - Bug #11759] URI breaks with frozen strings
Date: Mon, 07 Dec 2015 07:19:01 +0000	[thread overview]
Message-ID: <redmine.journal-55282.20151207071900.3130004384af94c2@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11759.20151202000114@ruby-lang.org

Issue #11759 has been updated by Yukihiro Matsumoto.


I prefer `String.new()` to `"".dup` because the former describes intention (of creating a buffer).
In fact, my best choice is introducing `String#+` that returns a mutable copy of a string.

For the size of byte code and performance, we can expect future optimization.

Matz.


----------------------------------------
Bug #11759: URI breaks with frozen strings
https://bugs.ruby-lang.org/issues/11759#change-55282

* 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/

  parent reply	other threads:[~2015-12-07  6:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-11759.20151202000114@ruby-lang.org>
2015-12-02  0:01 ` [ruby-core:71785] [Ruby trunk - Bug #11759] [Open] URI breaks with frozen strings mperham
2015-12-02  1:18 ` [ruby-core:71786] [Ruby trunk - Bug #11759] " me
2015-12-02  1:30 ` [ruby-core:71787] " me
2015-12-02  1:47   ` [ruby-core:71788] " Eric Wong
2015-12-02  3:56 ` [ruby-core:71790] " me
2015-12-02  4:10 ` [ruby-core:71791] " akr
2015-12-02  7:11 ` [ruby-core:71797] " colin
2015-12-02 21:36   ` [ruby-core:71804] " Eric Wong
2015-12-03  5:20 ` [ruby-core:71812] " colin
2015-12-03 23:41   ` [ruby-core:71820] " Eric Wong
2015-12-05 16:20 ` [ruby-core:71846] " colin
2015-12-07  7:19 ` matz [this message]
2015-12-07 15:59 ` [ruby-core:71910] " colin
2015-12-08 21:35   ` [ruby-core:71957] " Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-55282.20151207071900.3130004384af94c2@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).