TimeZone requires preloading before #freeze #1977

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
6 participants

'Can't modify frozen object' when calling #freeze after instantiation

Although I did add tests to this which should have failed, for some reason they didn't. If someone with more knowledge of Rails dependencies could help me out I would appreciate it.

The issue this fixes is here: #1966

There is a 100% repeatable (on the 3 MacBooks I tried) bug wherein executing the following:

rails new foo
cd foo
bundle install
rails console

And within IRB:

ActiveSupport::TimeZone.new('Alaska').freeze

Raises a Can't modify a frozen object RuntimeError.

Although I can get this error to occur every time, I cannot get it to be reproduced in a test.

I hope this at least puts everyone on the right track to tracking down this problem.

activesupport/lib/active_support/values/time_zone.rb
@@ -289,6 +289,12 @@ module ActiveSupport
Time.now.utc.in_time_zone(self)
end
+ # Preload information prior to freezing
+ def freeze
+ tzinfo; utc_offset;
@dasch

dasch Jul 9, 2011

Contributor

Better split this line into two, and get rid of the semicolons.

@sikachu

sikachu Jul 11, 2011

Member

I'm agree. Can you amend your patch and force-push to your branch?

@jfelchner

jfelchner Jul 16, 2011

Sorry guys, was on vacation. I can certainly do that. I'll get it in today.

jfelchner added some commits Jul 6, 2011

TimeZone requires preloading before #freeze
'Can't modify frozen object' when calling #freeze after instantiation

@sikachu Sorry for the delay. Hope this meets your approval. Thanks again for taking a look at this!

Contributor

akaspick commented Aug 15, 2011

+1

Member

arunagw commented Jan 8, 2012

Not sure about the orignal issue. But what's going on about this PR?

Contributor

isaacsanders commented May 1, 2012

Is this still an issue?

This was previously an issue for me but I haven't been hacking on timezones in a while.

I just tried it again and cannot reproduce. I'll close it for now.

@jfelchner jfelchner closed this May 1, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment