From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 81B5F19C0009 for ; Wed, 2 Dec 2015 10:15:59 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id B21EEB5D83F for ; Wed, 2 Dec 2015 10:47:22 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 13B9D18CC7AF for ; Wed, 2 Dec 2015 10:47:22 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 6BC841205CA; Wed, 2 Dec 2015 10:47:21 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by neon.ruby-lang.org (Postfix) with ESMTP id 23F641204EF for ; Wed, 2 Dec 2015 10:47:18 +0900 (JST) Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 00C7D205E6; Wed, 2 Dec 2015 01:47:16 +0000 (UTC) Date: Wed, 2 Dec 2015 01:47:16 +0000 From: Eric Wong To: Ruby developers Message-ID: <20151202014716.GA25333@dcvr.yhbt.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ML-Name: ruby-core X-Mail-Count: 71788 Subject: [ruby-core:71788] Re: [Ruby trunk - Bug #11759] URI breaks with frozen strings X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Hi David, a new problem is to_s now returns a frozen string. This has the potential to break many existing callers of to_s. Perhaps the following (untested) one-liner is enough? --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -1339,7 +1339,7 @@ def normalize! # Constructs String from URI # def to_s - str = '' + str = ''.freeze.dup if @scheme str << @scheme str << ':'.freeze I added the extra 'freeze' instead of just calling 'dup' to avoid allocating the extra object when frozen string literals are not enabled. But yeah, problems like this is why I remain against frozen string literals for 3.0 (but I'm alright with the opt-in magic comment).