Bug #4161
closedReXML wants "elements.each" argument to be not frozen
Description
=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
Updated by naruse (Yui NARUSE) over 13 years ago
- Status changed from Open to Assigned
- Assignee set to kou (Kouhei Sutou)
=begin
=end
Updated by ko1 (Koichi Sasada) almost 13 years ago
Suto-san,
How about it?
Updated by kou (Kouhei Sutou) almost 13 years ago
I'm sorry. I didn't noticed it. I'll check it soon.
Updated by kou (Kouhei Sutou) almost 13 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r31998.
Pavel, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- ChangeLog: fix ticket number at r31995. fixes #4161 is correct.