Forum: Ruby Troubleshooting frozen object in tzinfo_timezone

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Af59b773b8812a90dde7ebd282d652c6?d=identicon&s=25 Morten (Guest)
on 2007-01-30 01:15
(Received via mailing list)
Hi. Off and on I get a "can't modify frozen object" when working with
the tzinfo_timezone plugin. I've added some debugging in the code to try
and track down what goes wrong:

   def tzinfo
     RAILS_DEFAULT_LOGGER.debug("TZINFO STATE '#{@tzinfo}' class
#{@tzinfo.class} frozen? #{@tzinfo.frozen?}")
     return @tzinfo if @tzinfo
     RAILS_DEFAULT_LOGGER.debug("TZINFO ASSIGN TO #{MAPPING[name]}")
     begin
       @tzinfo = MAPPING[name]
     rescue TypeError => type_error
       RAILS_DEFAULT_LOGGER.debug("TZINFO TYPE ERROR #{type_error}")
       raise type_error
     end
     RAILS_DEFAULT_LOGGER.debug("TZINFO ASSIGNED TO #{@tzinfo}")
     if String === @tzinfo
       @tzinfo = TZInfo::Timezone.get(@tzinfo)
       MAPPING[name] = @tzinfo
     end
     @tzinfo
   end


When the error occurs, the following makes it to the log:

TZINFO STATE '' class NilClass frozen? false
TZINFO ASSIGN TO Europe/Amsterdam
TZINFO TYPE ERROR can't modify frozen object

Which means, that @tzinfo is nil, and yet, the line

  @tzinfo = MAPPING[name]

Causes a TypeError. MAPPING is a hash. I'm mildly confused. Anyone able
to shed some light on what might be the issue or how to dig further into
the problem?

ruby 1.8.4 (2005-12-24) [x86_64-linux]

Thanks.

Morten
This topic is locked and can not be replied to.