Skip to content

Commit

Permalink
Merge pull request #620 from JuliaIO/dev
Browse files Browse the repository at this point in the history
Draft: new version
  • Loading branch information
JonasIsensee authored Nov 25, 2024
2 parents 131d498 + c91153b commit b8b0f9a
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 50 deletions.
34 changes: 19 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
## 0.5.10
- fix regression for `UInt32`
- **Deprecation**: Do not rely on JLD2 to load a compression library. This feature will be removed in a future release. Instead explicitly add `using` statements into your scripts.

## 0.5.9
- fix regression for `Union{Bool,Nothing}` array elements (#617)
- fix printing issue in `printtoc`
- fix printing issue in `printtoc`

## 0.5.8
- Stop using `Base.module_keys` as it is removed on nightly

## 0.5.7
- Fix edge case for uninitialized Vlens

## 0.5.6
- Add Aqua tests and eliminate method ambiguities

## 0.5.5
- Experimental support for writing to and reading from `IO` objects e.g. `jldopen(io, "r")`

Expand All @@ -27,7 +31,7 @@ that may get GC'ed while storing is in progress! (#603)

## 0.5.1
- Bugfix and added test for bug introduced in v0.5.0

## 0.5.0
- Improved encoding of committed datatypes.
This fixes longstanding issues but new files will not be loaded correctly with JLD2 versions prior to `v0.5.0`.
Expand Down Expand Up @@ -58,7 +62,7 @@ that may get GC'ed while storing is in progress! (#603)
- fix `Upgrade` for Singleton types

## 0.4.50
- Don't hide exception data during loading and saving (#569)
- Don't hide exception data during loading and saving (#569)

## 0.4.49
- update compat bounds
Expand All @@ -68,7 +72,7 @@ that may get GC'ed while storing is in progress! (#603)
- fix behaviour for unnormalized strings
- add missing method for load_attributes
- clean up `using` statements

## 0.4.47
- fix loading structs with more than 256 fields (#558)

Expand Down Expand Up @@ -107,7 +111,7 @@ that may get GC'ed while storing is in progress! (#603)
- restrict default Dict encoding to Base implementations

## 0.4.37
- Update Dict encoding for latest julia
- Update Dict encoding for latest julia

## 0.4.36
- compat bound for TranscodingStreams.jl
Expand All @@ -129,22 +133,22 @@ that may get GC'ed while storing is in progress! (#603)
## 0.4.31
- fix UInt32 truncation error for absurdly large array sizes
- move test-files to a separate repo

## 0.4.30
- allow loading compressed files during precompilation #446 (@marius311)

## 0.4.29
- added `Upgrade` feature

## 0.4.28
- compatibility to julia v1.9-dev (@eschnett)

## 0.4.26
- fix identity relations with custom serialization

## 0.4.25
- remove leftover debug statement

## 0.4.24
- read-only support for `JLD.jl` files
- read-only support for many HDF5 files. Most test files of HDF5.jl are covered
Expand All @@ -155,14 +159,14 @@ that may get GC'ed while storing is in progress! (#603)

## 0.4.23
- Support for `const` fields in mutable structs

## 0.4.22
- Fix reconstruction of partially initialized structs

## 0.4.21
- Add explicit type mapping
- Add explicit type mapping

## 0.4.20
## 0.4.20
- TTFX improvements
- Add a comment on jldsave (@BoundaryValueProblems)
## 0.4.19
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "JLD2"
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
version = "0.5.9"
version = "0.5.10"

[deps]
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
Expand Down
31 changes: 7 additions & 24 deletions src/compression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,18 @@ end
# Dynamic Package Loading Logic copied from FileIO
const load_locker = Base.ReentrantLock()

function _findmod(f::Symbol)
for (u,v) in Base.loaded_modules
(Symbol(v) == f) && return u
end
nothing
end

function topimport(modname)
@info "Attempting to dynamically load $modname"
@eval Base.__toplevel__ import $modname
u = _findmod(modname)
@eval $modname = Base.loaded_modules[$u]
end

function checked_import(pkg::Symbol)
lock(load_locker) do
# kludge for test suite
if isdefined(Main, pkg)
m1 = getfield(Main, pkg)
isa(m1, Module) && return false, m1
for m in Base.loaded_modules_array()
(Symbol(m) == pkg) && return false, m
end
if isdefined(JLD2, pkg)
m1 = getfield(JLD2, pkg)
isa(m1, Module) && return false, m1
@info "Attempting to dynamically load $pkg"
@eval Base.__toplevel__ import $pkg
for m in Base.loaded_modules_array()
(Symbol(m) == pkg) && return true, m
end
m = _findmod(pkg)
(m === nothing) || return false, Base.loaded_modules[m]
topimport(pkg)
return true, Base.loaded_modules[_findmod(pkg)]
throw(InternalError("Module $pkg could not be loaded."))
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/data/number_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function jltype(f::JLDFile, dt::FixedPointDatatype)
elseif dt.size == 1
return signed ? SameRepr{Int8}() : SameRepr{UInt8}()
elseif dt.size == 4
return signed ? SameRepr{Int32}() : SameRepr{Int32}()
return signed ? SameRepr{Int32}() : SameRepr{UInt32}()
elseif dt.size == 2
return signed ? SameRepr{Int16}() : SameRepr{UInt16}()
elseif dt.size == 16
Expand Down
2 changes: 1 addition & 1 deletion src/data/reconstructing_datatypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function _resolve_type(rr::MappedRepr{T,DataTypeODR},
hasparams::Bool,
params) where T
parts = split(mypath, '.')
for mod in values(Base.loaded_modules)
for mod in Base.loaded_modules_array()
resolution_attempt = _resolve_type_singlemodule(rr,
mod,
parts,
Expand Down
14 changes: 8 additions & 6 deletions src/data/specialcased_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,15 @@ wconvert(::Type{String}, x::Module) = string(x)
function rconvert(::Type{Module}, x::String)
pkg = Symbol(x)
# Try to find the module
# Start with the method used to find compression libraries
m =_findmod(pkg)
isnothing(m) || return Base.loaded_modules[m]
@info "Encountered reference to module $x, but it is not currently loaded."
for m in Base.loaded_modules_array()
(Symbol(m) == pkg) && return m
end
@warn "Encountered reference to module $x, but it is not currently loaded."
return try
topimport(pkg)
Base.loaded_modules[_findmod(pkg)]
@eval Base.__toplevel__ import $pkg
for m in Base.loaded_modules_array()
(Symbol(m) == pkg) && return m
end
catch
@warn "Could not load module $x. Returning a dummy module"
Module(Symbol(x*"_dummy"))
Expand Down
19 changes: 18 additions & 1 deletion test/loadsave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -847,4 +847,21 @@ end
loaded_data = load(fn, "data")
@test !isassigned(loaded_data, 2)
@test loaded_data[1] == :a
end
end

@testset "Issue #619 - Number type turnaround" begin
fn = joinpath(mktempdir(), "number_type_turnaround.jld2")
types = [UInt8, Int8, UInt16, Int16, UInt32, Int32, UInt64, Int64, UInt128, Int128, Float16, Float32, Float64]
jldopen(fn, "w") do f
for t in types
f[string(t)] = typemax(t)
end
end
jldopen(fn) do f
for t in types
v = f[string(t)]
@test v isa t
@test v == typemax(t)
end
end
end
2 changes: 1 addition & 1 deletion test/modules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ S = BType(x)
end

@testset "name collisions" begin
mods = collect(values(Base.loaded_modules))
mods = Base.loaded_modules_array()
# use whichever module would not be found first in a linear search
M = findfirst(==(A), mods) < findfirst(==(B), mods) ? B : A
x = M.SameNameType(42)
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using JLD2, FileIO
using Test
using CodecZlib, CodecBzip2, CodecZstd, CodecLz4

function better_success(cmd)
fn1, _ = mktemp()
Expand Down

2 comments on commit b8b0f9a

@JonasIsensee
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release Notes:

  • fix recently introduced regression where UInt32 was converted to Int32 on load.
  • deprecation: Do not rely on JLD2 loading compression libraries. This is not fully stable due to worldage issues and it will be removed in a future release. (Instead do using CodecXX yourself)

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/120148

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.10 -m "<description of version>" b8b0f9adaff35dbf39e0e4d58c164ff9f278f54b
git push origin v0.5.10

Please sign in to comment.