Freezing objects without Kernel#freeze

H

Han Holl

Hello,

Having some trouble with REXML, but this post is not (primarily)
about that.
REXML-2.7.1 informs me that it cannot modify a frozen object.
The culprit is an attribute with a value of "lym<II", and rexml
does a copy = input.clone and copy.gsub!() to do entity replacement.
My problem: who froze that string.
To detect that, I put the following at the start of the program:

$GGG = File.open('/tmp/freeze', 'a')
module Kernel
alias o_freeze freeze
def freeze
$GGG.puts "Freeze #{self.class}:#{self.object_id} #{self}\n"
$GGG.puts caller(0)
$GGG.flush
o_freeze
end
end
and in rexml/text.rb a begin..rescue TypeError ... end to print the
object_id of the frozen string.
It never showed up in /tmp/freeze.
My question: how can REXML, which is pure ruby, freeze something
without it showing up in the file produced by the above trap?
Is there another way of freezing that bypasses Kernel#freeze ?

Cheers,

Han Holl

PS REXML-3.1.1 doesn't produce this error message, so it's not urgent,
but I am curious.
 
T

ts

H> Is there another way of freezing that bypasses Kernel#freeze ?

You have this case

svg% ruby -e 'a = {}; b = "a"; a = 12; p a.keys[0].frozen?'
true
svg%


Guy Decoux
 
H

Han Holl

H> Is there another way of freezing that bypasses Kernel#freeze ?

You have this case

svg% ruby -e 'a = {}; b = "a"; a = 12; p a.keys[0].frozen?'
true
svg%


Guy Decoux


Thanks Guy,

That's what must have happened.

Cheers,

Han Holl
 

Members online

Forum statistics

Threads
474,262
Messages
2,571,058
Members
48,769
Latest member
Clifft

Latest Threads

Top