From 105f5ad23cb6156aca55dfea36678cfc7de178f4 Mon Sep 17 00:00:00 2001 From: ThomasBreuer Date: Wed, 18 Sep 2024 14:42:41 +0200 Subject: [PATCH] update the Julia code for downloading files - avoid the call `JuliaImportPackage("Downloads")`, which somehow does not work as expected in certain situations, see oscar-system/GAP.jl/issues/1040 - update the code of the function such that it contains the changes from oscar-system/GAP.jl/pull/961 (Yes, the new code looks ugly, and the next GAP.jl version will contain support for the "call with catch *and* keyword arguments" situation.) --- gap/Julia.g | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gap/Julia.g b/gap/Julia.g index 34028a4..e438d67 100644 --- a/gap/Julia.g +++ b/gap/Julia.g @@ -7,16 +7,20 @@ # (Note that Downloads.jl gets loaded by GAP.jl.) # For that, we replace the code of `PKGMAN_DownloadURL`. -if IsBound(Julia) and JuliaImportPackage("Downloads") = true then +if IsBound(Julia) then MakeReadWriteGlobal("PKGMAN_DownloadURL"); UnbindGlobal("PKGMAN_DownloadURL"); BindGlobal("PKGMAN_DownloadURL", function(url) local res; - res := CallJuliaFunctionWithCatch(Julia.Downloads.download, - [Julia.string(url), Julia.IOBuffer()]); - if res.ok then - res := Julia.String(Julia.("take!")(res.value)); + res := Julia.GAP.call_with_catch( + Julia.GAP.UnwrapJuliaFunc(Julia.GAP.kwarg_wrapper), + GAPToJulia([Julia.GAP.Packages.Downloads.download, + [Julia.string(url), Julia.IOBuffer()], + rec(downloader:= Julia.getindex( + Julia.GAP.Packages.DOWNLOAD_HELPER))])); + if res[1] = true then + res := Julia.String(Julia.take\!(res[2])); return rec(success := true, result := JuliaToGAP(IsString, res)); else return rec(success := false);