diff --git a/src/C/context.jl b/src/C/context.jl index 57c7d3ad..07135409 100644 --- a/src/C/context.jl +++ b/src/C/context.jl @@ -188,12 +188,8 @@ function init_context() Py_InitializeEx(0) atexit() do CTX.is_initialized = false - if CTX.version === missing || CTX.version < v"3.6" - Py_Finalize() - else - if Py_FinalizeEx() == -1 - @warn "Py_FinalizeEx() error" - end + if Py_FinalizeEx() == -1 + @warn "Py_FinalizeEx() error" end end end @@ -223,8 +219,8 @@ function init_context() error("Cannot parse version from version string: $(repr(verstr))") end CTX.version = VersionNumber(vermatch.match) - v"3.5" ≤ CTX.version < v"4" || error( - "Only Python 3.5+ is supported, this is Python $(CTX.version) at $(CTX.exe_path===missing ? "unknown location" : CTX.exe_path).", + v"3.9" ≤ CTX.version < v"4" || error( + "Only Python 3.9+ is supported, this is Python $(CTX.version) at $(CTX.exe_path===missing ? "unknown location" : CTX.exe_path).", ) @debug "Initialized PythonCall.jl" CTX.is_embedded CTX.is_initialized CTX.exe_path CTX.lib_path CTX.lib_ptr CTX.pyprogname CTX.pyhome CTX.version diff --git a/src/C/pointers.jl b/src/C/pointers.jl index 22343104..d7441960 100644 --- a/src/C/pointers.jl +++ b/src/C/pointers.jl @@ -2,8 +2,7 @@ const CAPI_FUNC_SIGS = Dict{Symbol,Pair{Tuple,Type}}( # INITIALIZE :Py_Initialize => () => Cvoid, :Py_InitializeEx => (Cint,) => Cvoid, - :Py_Finalize => () => Cvoid, - :Py_FinalizeEx => () => Cint, # 3.6+ + :Py_FinalizeEx => () => Cint, :Py_AtExit => (Ptr{Cvoid},) => Cint, :Py_IsInitialized => () => Cint, :Py_SetPythonHome => (Ptr{Cwchar_t},) => Cvoid, @@ -283,11 +282,8 @@ const POINTERS = CAPIPointers() @eval init_pointers(p::CAPIPointers = POINTERS, lib::Ptr = CTX.lib_ptr) = begin $([ - if name == :Py_FinalizeEx - :(p.$name = dlsym_e(lib, $(QuoteNode(name)))) - else - :(p.$name = dlsym(lib, $(QuoteNode(name)))) - end for name in CAPI_FUNCS + :(p.$name = dlsym(lib, $(QuoteNode(name)))) + for name in CAPI_FUNCS ]...) $( [ diff --git a/src/Core/err.jl b/src/Core/err.jl index 5cde77ec..a7e936c1 100644 --- a/src/Core/err.jl +++ b/src/Core/err.jl @@ -176,47 +176,37 @@ function _showerror(io::IO, e::PyException, bt; backtrace = true) pystr(String, x.lineno), ) for x in pyimport("traceback").extract_tb(e.b) ] - if Base.VERSION < v"1.6.0-rc1" - for (i, (name, fname, lineno)) in enumerate(reverse(fs)) - println(io) - printstyled(io, " [", i, "] ") - printstyled(io, name, bold = true) - printstyled(io, " at ") - printstyled(io, fname, ":", lineno, bold = true) - end - else - mcdict = Dict{String,Symbol}() - mccyclyer = - Iterators.Stateful(Iterators.cycle(Base.STACKTRACE_MODULECOLORS)) - # skip a couple as a basic attempt to make the colours different from the Julia stacktrace - popfirst!(mccyclyer) - popfirst!(mccyclyer) - for (i, (name, fname, lineno)) in enumerate(reverse(fs)) - println(io) - printstyled(io, " [", i, "] ") - printstyled(io, name, bold = true) - println(io) - printstyled(io, " @ ", color = :light_black) - mod = file_to_pymodule(fname) - if mod !== nothing - # print the module, with colour determined by the top level name - tmod = first(split(mod, ".", limit = 2)) - color = get!(mcdict, tmod) do - popfirst!(mccyclyer) - end - printstyled(io, mod, " ", color = color) + mcdict = Dict{String,Symbol}() + mccyclyer = + Iterators.Stateful(Iterators.cycle(Base.STACKTRACE_MODULECOLORS)) + # skip a couple as a basic attempt to make the colours different from the Julia stacktrace + popfirst!(mccyclyer) + popfirst!(mccyclyer) + for (i, (name, fname, lineno)) in enumerate(reverse(fs)) + println(io) + printstyled(io, " [", i, "] ") + printstyled(io, name, bold = true) + println(io) + printstyled(io, " @ ", color = :light_black) + mod = file_to_pymodule(fname) + if mod !== nothing + # print the module, with colour determined by the top level name + tmod = first(split(mod, ".", limit = 2)) + color = get!(mcdict, tmod) do + popfirst!(mccyclyer) end - if isfile(fname) && - :stacktrace_contract_userdir in names(Base, all = true) && - Base.stacktrace_contract_userdir() - if :replaceuserpath in names(Base, all = true) - fname = Base.replaceuserpath(fname) - elseif :contractuser in names(Base.Filesystem, all = true) - fname = Base.Filesystem.contractuser(fname) - end + printstyled(io, mod, " ", color = color) + end + if isfile(fname) && + :stacktrace_contract_userdir in names(Base, all = true) && + Base.stacktrace_contract_userdir() + if :replaceuserpath in names(Base, all = true) + fname = Base.replaceuserpath(fname) + elseif :contractuser in names(Base.Filesystem, all = true) + fname = Base.Filesystem.contractuser(fname) end - printstyled(io, fname, ":", lineno, color = :light_black) end + printstyled(io, fname, ":", lineno, color = :light_black) end catch err print(io, "")