Skip to content

Instantly share code, notes, and snippets.

@cheald
Created October 7, 2013 22:56
Show Gist options
  • Save cheald/6876403 to your computer and use it in GitHub Desktop.
Save cheald/6876403 to your computer and use it in GitHub Desktop.
# The minimal reproduction case
require 'active_support/all'
Time.zone = "UTC"
Marshal.load(Marshal.dump(Time.zone.now))
# Dumping in 2.1, 2.0, and RBX-2.0.0
r2.1.0dev :001 > require 'active_support/all'
=> true
2.1.0dev :002 > Time.zone = "UTC"
=> "UTC"
2.1.0dev :003 > Marshal.dump(Time.zone.now)
=> "\x04\bU: ActiveSupport::TimeWithZone[\bIu:\tTime\r\xF6d\x1C\xC0\x9F(\xE3\xD0\t:\rnano_numi\x02\xC1\x02:\rnano_deni\x06:\rsubmicro\"\apP:\tzoneI\"\bUTC\x06:\x06ETI\"\bUTC\x06;\vT@\t"
2.0.0p247 :001 > require 'active_support/all'
=> true
2.0.0p247 :002 > Time.zone = "UTC"
=> "UTC"
2.0.0p247 :003 > Marshal.dump(Time.zone.now)
=> "\x04\bU: ActiveSupport::TimeWithZone[\bIu:\tTime\r\xF6d\x1C\xC0\xD8\xB4\x81\xD6\t:\rnano_numi\x02`\x02:\rnano_deni\x06:\rsubmicro\"\a`\x80:\tzoneI\"\bUTC\x06:\x06ETI\"\bUTC\x06;\vT@\t"
rubinius-2.0.0n280 :001 > require 'active_support/all'
=> true
rubinius-2.0.0n280 :002 > Time.zone = "UTC"
=> "UTC"
rubinius-2.0.0n280 :003 > Marshal.dump(Time.zone.now)
=> "\x04\bU: ActiveSupport::TimeWithZone[\bIu:\tTime\r\xF6d\x1C\xC0Z\x87\xAE\xD8\x06:\tzoneI\"\bUTC\x06:\x06ETI\"\bUTC\x06;\bT@\a"
# Loading
# In RBX, loading the string from Ruby 2.1 works:
rubinius-2.0.0n280 :004 > Marshal.load("\x04\bU: ActiveSupport::TimeWithZone[\bIu:\tTime\r\xF6d\x1C\xC0\x9F(\xE3\xD0\t:\rnano_numi\x02\xC1\x02:\rnano_deni\x06:\rsubmicro\"\apP:\tzoneI\"\bUTC\x06:\x06ETI\"\bUTC\x06;\vTt")
[2013-10-07 22:52:14 UTC, "UTC", 2013-10-07 22:52:14 UTC]
=> Mon, 07 Oct 2013 22:52:14 UTC +00:00
# The 2.0 string works
rubinius-2.0.0n280 :005 > Marshal.load("\x04\bU: ActiveSupport::TimeWithZone[\bIu:\tTime\r\xF6d\x1C\xC0\xD8\xB4\x81\xD6\t:\rnano_numi\x02`\x02:\rnano_deni\x06:\rsubmicro\"\a`\x80:\tzoneI\"\bUTC\x06:\x06ETI\"\bUTC\x06;T@\t")
[2013-10-07 22:53:40 UTC, "UTC", 2013-10-07 22:53:40 UTC]
=> Mon, 07 Oct 2013 22:53:40 UTC +00:00
# The RBX string blows up
rubinius-2.0.0n280 :006 > Marshal.load("\x04\bU: ActiveSupport::TimeWithZone[\bIu:\tTime\r\xF6d\x1C\xC0Z\x87\xAE\xD8\x06:\tzoneI\"\bUTC\x06:\x06ETI\"\bUTC\x06;\bT@\a")
[2013-10-07 22:54:10 UTC, "UTC", "UTC"]
NoMethodError: undefined method `utc' on an instance of String.
from kernel/delta/kernel.rb:78:in `utc (method_missing)'
from /usr/local/rvm/gems/rbx-head/gems/activesupport-3.2.15.rc1/lib/active_support/time_with_zone.rb:321:in `marshal_load'
from kernel/common/marshal.rb:830:in `construct_user_marshal'
from kernel/common/marshal.rb:500:in `construct'
from kernel/common/marshal.rb:1176:in `load'
from (irb):6
from kernel/common/block_environment.rb:53:in `call_on_instance'
from kernel/common/eval.rb:176:in `eval'
from kernel/common/kernel.rb:440:in `loop'
from kernel/bootstrap/proc.rb:20:in `call'
from kernel/common/throw_catch.rb:30:in `catch'
from kernel/common/throw_catch.rb:8:in `register'
from kernel/common/throw_catch.rb:29:in `catch'
from kernel/bootstrap/proc.rb:20:in `call'
from kernel/common/throw_catch.rb:30:in `catch'
from kernel/common/throw_catch.rb:8:in `register'
from kernel/common/throw_catch.rb:29:in `catch'
from /usr/local/rvm/gems/rbx-head@global/gems/rubysl-irb-2.0.3/bin/irb:12:in `__script__'
from kernel/common/kernel.rb:427:in `load'
from /usr/local/rvm/gems/rbx-head@global/bin/irb:19:in `__script__'
from kernel/delta/code_loader.rb:66:in `load_script'
from kernel/delta/code_loader.rb:182:in `load_script'
from kernel/loader.rb:648:in `script'
from kernel/loader.rb:830:in `main'rubinius-2.0.0n280 :007 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment