Skip to content

Commit

Permalink
A few fixes for julia master (#1059)
Browse files Browse the repository at this point in the history
* Fix breakage due to JuliaLang/julia#51319

`cconvert` does not return an array anymore and cannot be used with `reinterpret`.
Fix to use the underlying `transcode` function directly,
which is also consistent with the `Cstring` version.

* Fix doc test
  • Loading branch information
yuyichao authored Oct 30, 2023
1 parent 2a9f077 commit 04c4778
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ julia = "1.4"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[targets]
test = ["Test"]
test = ["Test", "REPL"]
6 changes: 4 additions & 2 deletions deps/depsutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ function _preserveas!(dest::Vector{UInt8}, ::Type{Cstring}, x::AbstractString)
end

function _preserveas!(dest::Vector{UInt8}, ::Type{Cwstring}, x::AbstractString)
s = reinterpret(UInt8, Base.cconvert(Cwstring, x))
copyto!(resize!(dest, length(s)), s)
s = reinterpret(UInt8, transcode(Cwchar_t, String(x)))
len = length(s)
copyto!(resize!(dest, len + sizeof(Cwchar_t)), s)
dest[len + 1:len + sizeof(Cwchar_t)] .= 0
return pointer(dest)
end

Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using PyCall
using PyCall: hasproperty
using Test, Dates, Serialization
using REPL # for Docs.doc methods

filter(f, itr) = collect(Iterators.filter(f, itr))
filter(f, d::AbstractDict) = Base.filter(f, d)
Expand Down

0 comments on commit 04c4778

Please sign in to comment.