Chipping Away At Hash Keys Reveals Human Futility
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.