JuliaTime / TimeZones.jl

IANA time zone database access for the Julia programming language
Other
87 stars 52 forks source link

If TimeZone is installed and built on a newer version of Julia that TimeZone version is unusable on older Julia versions #288

Closed KristofferC closed 3 years ago

KristofferC commented 4 years ago
julia> using TimeZones # 1.5.1

julia> tz"UTC"
ERROR: LoadError: Cannot read stream serialized with a newer version of Julia.
Got data version 12 > current version 10
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] readheader(::Serialization.Serializer{IOStream}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Serialization/src/Serialization.jl:715
 [3] handle_deserialize(::Serialization.Serializer{IOStream}, ::Int32) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Serialization/src/Serialization.jl:878
 [4] deserialize(::Serialization.Serializer{IOStream}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Serialization/src/Serialization.jl:773
 [5] deserialize at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Serialization/src/Serialization.jl:760 [inlined]
 [6] open(::typeof(Serialization.deserialize), ::String, ::Vararg{String,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at ./io.jl:325
 [7] open at ./io.jl:323 [inlined]
 [8] (::TimeZones.var"#3#4"{String})() at /Users/kristoffercarlsson/.julia/packages/TimeZones/v0mfN/src/types/timezone.jl:50
 [9] get!(::TimeZones.var"#3#4"{String}, ::Dict{String,Tuple{TimeZone,TimeZones.Class}}, ::String) at ./dict.jl:450
 [10] TimeZone(::String, ::TimeZones.Class) at /Users/kristoffercarlsson/.julia/packages/TimeZones/v0mfN/src/types/timezone.jl:46 (repeats 2 times)
 [11] @tz_str(::LineNumberNode, ::Module, ::Any) at /Users/kristoffercarlsson/.julia/packages/TimeZones/v0mfN/src/types/timezone.jl:86
in expression starting at REPL[2]:1

Because I happened to install TimeZones on julia master first.

omus commented 4 years ago

Currently TimeZones.jl uses serialization to store time zones with pre-computed transitions. As Julia and TimeZones have improved performance over time I'm hoping to switch over to calculating these transitions on the fly which would remove any reliance on serialization and thus avoid this problem.

If it turns out that this approach is too slow we should be able to store this information on disk using alternative storage methods like a custom format or another serialization format.

oxinabox commented 4 years ago

If we have to keep storing it with serialization can we at least do something like including the julia version in the file path.

oxinabox commented 3 years ago

This is super-annoying

oxinabox commented 3 years ago

If we have to keep storing it with serialization can we at least do something like including the julia version in the file path.

I will do this today.

Interestingly this no longer reproduced for tz"UTC" I guess because we now special case that in the parser to be faster. But does fail as expected for tz"America/Winnipeg"

omus commented 3 years ago

Fixed in TimeZones 1.5.3