hoodwink.d enhanced
RSS
2.0
XHTML
1.0

RedHanded

Chipping Away At Hash Keys Reveals Human Futility #

by why in inspect

For the last few days, the Hobix list has been stumped trying to uncover why Ruby keeps throwing up a can't modify frozen object exception. We’re just loading a YAML file that contains a list of plugins to load and optional settings for each plugin:

 - hobix/out/rss
 - hobix/out/atom
 - hobix/publish/ping: [http://ping.blo.gs:80/, http://rpc.weblogs.com:80/RPC2]

The code was attempting to untaint the Hash keys if they looked like safe file paths. But, since Hash keys are automatically frozen and immutable, Ruby throws an exception. Fine, fine. Lesson is: make sure you dup the Hash key before you need to modify it.

The real confusion, though, lied with a variation between Ruby 1.8.2-2 and Ruby 1.8.2-3 under Debian. It looks like the YAML module under 1.8.2-2 doesn’t propagate the tainting flag.

said on 04 Apr 2005 at 13:47

First of all, “The real confusion lay with a variation…”

Secondly, I was under the impression that dup propigates the frozeness of objects. Is that not so?

said on 05 Apr 2005 at 00:23

”... dup propagates the frozenness ...”

Comments are closed for this entry.