From: Koichi Sasada Date: 2011-06-11T15:30:58+09:00 Subject: [ruby-core:36986] [Ruby 1.9 - Bug #4161] ReXML wants "elements.each" argument to be not frozen Issue #4161 has been updated by Koichi Sasada. Suto-san, How about it? ---------------------------------------- Bug #4161: ReXML wants "elements.each" argument to be not frozen http://redmine.ruby-lang.org/issues/4161 Author: Pavel Shved Status: Assigned Priority: Normal Assignee: Kouhei Sutou Category: Target version: ruby -v: ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] =begin Here's a simple program that uses ReXML: require 'rexml/document' doc = REXML::Document.new File.new(ARGV[0]) query = "element".freeze doc.elements.each(query) do |elem| puts elem.name end I expected the program to work without errors (when called with a valid XML file as its first command-line argument). However the program fails with a backtrace: /home/pavel/ruby-1.9/lib/ruby/1.9.1/rexml/parsers/xpathparser.rb:20:in `gsub!': can't modify frozen string (RuntimeError) from /home/pavel/ruby-1.9/lib/ruby/1.9.1/rexml/parsers/xpathparser.rb:20:in `parse' from /home/pavel/ruby-1.9/lib/ruby/1.9.1/rexml/xpath_parser.rb:57:in `parse' from /home/pavel/ruby-1.9/lib/ruby/1.9.1/rexml/xpath.rb:64:in `each' from /home/pavel/ruby-1.9/lib/ruby/1.9.1/rexml/element.rb:906:in `each' from a.rb:5:in `
' If the string is not frozen, it works well. In ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux] it also works well. Is there any reason to require the argument of elements_each to be frozen? =end -- http://redmine.ruby-lang.org