From 67424ceada19b785ec2741c275e831a49aa42bab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Riedemann?= <38795484+longemen3000@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:41:44 -0400 Subject: [PATCH] Fix breakage caused by JuliaLang/julia/pull/53896 (#1133) * fix breakage caused by JuliaLang/julia/pull/53896 * make __wrap compatible with 1.11 RC --- src/utils.jl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index d12eb023..d1efe22e 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -245,10 +245,16 @@ end # one-liner suggested from ScottPJones consumeBOM(buf, pos) = (length(buf) >= 3 && buf[pos] == 0xef && buf[pos + 1] == 0xbb && buf[pos + 2] == 0xbf) ? pos + 3 : pos -if isdefined(Base,:wrap) - __wrap(x,pos) = Base.wrap(Array,x,pos) +if isdefined(Base, :Memory) + if isdefined(Base,:wrap) + __wrap(x) = Base.wrap(Array,x,length(x)) + __wrap(x::Array) = x + else + __wrap(x) = view(x,Base.OneTo(length(x))) + __wrap(x::Array) = x + end else - __wrap(x,pos) = x + __wrap(x) = x end # whatever input is given, turn it into an AbstractVector{UInt8} we can parse with @@ -267,7 +273,7 @@ end x = x.data return parent(x), first(x.indices), last(x.indices), tfile else #support from IOBuffer containing Memory - y = __wrap(x.data,length(x.data)) #generates a Vector{UInt8} from Memory{UInt8} + y = __wrap(x.data) #generates a Vector{UInt8} from Memory{UInt8}, if available. return y, x.ptr, x.size, tfile end elseif x isa Cmd || x isa IO