From: Kazuhiro NISHIYAMA Date: 2009-08-12T05:07:21+09:00 Subject: [ruby-dev:39069] [Bug #1929] str.dup.force_encodingが元のstrに影響を与えることがある チケット #1929 が更新されました。 (by Kazuhiro NISHIYAMA) まだ長いように思いますが、単体で再現できるものができたので送っておきます。 % cat c.rb #!/usr/bin/env ruby-trunk # -*- coding: utf-8 -*- require 'pstore' require 'cgi' require 'erb' def cache_file(c) 'c.db' end params = CGI::parse("category=%E3%81%A6%E3%81%99%E3%81%A8") categories = params['category'] categorized = {} $dump_categorized = proc do |file, line| $stderr.puts [file, line, categories.map{|e|[e[0].object_id, e[0].encoding]}].inspect $stderr.puts [file, line, categorized.map{|e|[e[0].object_id, e[0].encoding]}].inspect end $dump_categorized[__FILE__, __LINE__] categories.each do |c| PStore.new(cache_file(c)).transaction do |db| categorized[c] = db['category'] db.abort end end $dump_categorized[__FILE__, __LINE__] categorized.keys.each do |c| PStore.new(cache_file(c)).transaction do |db| db['category'] = {} unless db.root?('category') db['category'].update(categorized[c] || {}) end end $dump_categorized[__FILE__, __LINE__] categories.map{|e|ERB::Util.u(e)} $dump_categorized[__FILE__, __LINE__] % ruby-trunk c.rb -v ["c.rb", 18, [[10938200, #]]] ["c.rb", 18, []] ["c.rb", 26, [[10937000, #]]] ["c.rb", 26, [[10937100, #]]] ["c.rb", 33, [[10935120, #]]] ["c.rb", 33, [[10937100, #]]] ["c.rb", 35, [[10932440, #]]] ["c.rb", 35, [[10937100, #]]] % ruby-trunk -v ruby 1.9.2dev (2009-08-07 trunk 24439) [x86_64-linux] % ---------------------------------------- http://redmine.ruby-lang.org/issues/show/1929 ---------------------------------------- http://redmine.ruby-lang.org