Skip to content

Commit b9fee86

Browse files
authored
removing dead code supporting old versions of julia or python (#647)
Co-authored-by: Christopher Doris <github.com/cjdoris>
1 parent 7b3ddb2 commit b9fee86

File tree

3 files changed

+35
-53
lines changed

3 files changed

+35
-53
lines changed

src/C/context.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,8 @@ function init_context()
188188
Py_InitializeEx(0)
189189
atexit() do
190190
CTX.is_initialized = false
191-
if CTX.version === missing || CTX.version < v"3.6"
192-
Py_Finalize()
193-
else
194-
if Py_FinalizeEx() == -1
195-
@warn "Py_FinalizeEx() error"
196-
end
191+
if Py_FinalizeEx() == -1
192+
@warn "Py_FinalizeEx() error"
197193
end
198194
end
199195
end
@@ -223,8 +219,8 @@ function init_context()
223219
error("Cannot parse version from version string: $(repr(verstr))")
224220
end
225221
CTX.version = VersionNumber(vermatch.match)
226-
v"3.5" CTX.version < v"4" || error(
227-
"Only Python 3.5+ is supported, this is Python $(CTX.version) at $(CTX.exe_path===missing ? "unknown location" : CTX.exe_path).",
222+
v"3.9" CTX.version < v"4" || error(
223+
"Only Python 3.9+ is supported, this is Python $(CTX.version) at $(CTX.exe_path===missing ? "unknown location" : CTX.exe_path).",
228224
)
229225

230226
@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

src/C/pointers.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ const CAPI_FUNC_SIGS = Dict{Symbol,Pair{Tuple,Type}}(
22
# INITIALIZE
33
:Py_Initialize => () => Cvoid,
44
:Py_InitializeEx => (Cint,) => Cvoid,
5-
:Py_Finalize => () => Cvoid,
6-
:Py_FinalizeEx => () => Cint, # 3.6+
5+
:Py_FinalizeEx => () => Cint,
76
:Py_AtExit => (Ptr{Cvoid},) => Cint,
87
:Py_IsInitialized => () => Cint,
98
:Py_SetPythonHome => (Ptr{Cwchar_t},) => Cvoid,
@@ -283,11 +282,8 @@ const POINTERS = CAPIPointers()
283282

284283
@eval init_pointers(p::CAPIPointers = POINTERS, lib::Ptr = CTX.lib_ptr) = begin
285284
$([
286-
if name == :Py_FinalizeEx
287-
:(p.$name = dlsym_e(lib, $(QuoteNode(name))))
288-
else
289-
:(p.$name = dlsym(lib, $(QuoteNode(name))))
290-
end for name in CAPI_FUNCS
285+
:(p.$name = dlsym(lib, $(QuoteNode(name))))
286+
for name in CAPI_FUNCS
291287
]...)
292288
$(
293289
[

src/Core/err.jl

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -176,47 +176,37 @@ function _showerror(io::IO, e::PyException, bt; backtrace = true)
176176
pystr(String, x.lineno),
177177
) for x in pyimport("traceback").extract_tb(e.b)
178178
]
179-
if Base.VERSION < v"1.6.0-rc1"
180-
for (i, (name, fname, lineno)) in enumerate(reverse(fs))
181-
println(io)
182-
printstyled(io, " [", i, "] ")
183-
printstyled(io, name, bold = true)
184-
printstyled(io, " at ")
185-
printstyled(io, fname, ":", lineno, bold = true)
186-
end
187-
else
188-
mcdict = Dict{String,Symbol}()
189-
mccyclyer =
190-
Iterators.Stateful(Iterators.cycle(Base.STACKTRACE_MODULECOLORS))
191-
# skip a couple as a basic attempt to make the colours different from the Julia stacktrace
192-
popfirst!(mccyclyer)
193-
popfirst!(mccyclyer)
194-
for (i, (name, fname, lineno)) in enumerate(reverse(fs))
195-
println(io)
196-
printstyled(io, " [", i, "] ")
197-
printstyled(io, name, bold = true)
198-
println(io)
199-
printstyled(io, " @ ", color = :light_black)
200-
mod = file_to_pymodule(fname)
201-
if mod !== nothing
202-
# print the module, with colour determined by the top level name
203-
tmod = first(split(mod, ".", limit = 2))
204-
color = get!(mcdict, tmod) do
205-
popfirst!(mccyclyer)
206-
end
207-
printstyled(io, mod, " ", color = color)
179+
mcdict = Dict{String,Symbol}()
180+
mccyclyer =
181+
Iterators.Stateful(Iterators.cycle(Base.STACKTRACE_MODULECOLORS))
182+
# skip a couple as a basic attempt to make the colours different from the Julia stacktrace
183+
popfirst!(mccyclyer)
184+
popfirst!(mccyclyer)
185+
for (i, (name, fname, lineno)) in enumerate(reverse(fs))
186+
println(io)
187+
printstyled(io, " [", i, "] ")
188+
printstyled(io, name, bold = true)
189+
println(io)
190+
printstyled(io, " @ ", color = :light_black)
191+
mod = file_to_pymodule(fname)
192+
if mod !== nothing
193+
# print the module, with colour determined by the top level name
194+
tmod = first(split(mod, ".", limit = 2))
195+
color = get!(mcdict, tmod) do
196+
popfirst!(mccyclyer)
208197
end
209-
if isfile(fname) &&
210-
:stacktrace_contract_userdir in names(Base, all = true) &&
211-
Base.stacktrace_contract_userdir()
212-
if :replaceuserpath in names(Base, all = true)
213-
fname = Base.replaceuserpath(fname)
214-
elseif :contractuser in names(Base.Filesystem, all = true)
215-
fname = Base.Filesystem.contractuser(fname)
216-
end
198+
printstyled(io, mod, " ", color = color)
199+
end
200+
if isfile(fname) &&
201+
:stacktrace_contract_userdir in names(Base, all = true) &&
202+
Base.stacktrace_contract_userdir()
203+
if :replaceuserpath in names(Base, all = true)
204+
fname = Base.replaceuserpath(fname)
205+
elseif :contractuser in names(Base.Filesystem, all = true)
206+
fname = Base.Filesystem.contractuser(fname)
217207
end
218-
printstyled(io, fname, ":", lineno, color = :light_black)
219208
end
209+
printstyled(io, fname, ":", lineno, color = :light_black)
220210
end
221211
catch err
222212
print(io, "<error while printing stacktrace: $err>")

0 commit comments

Comments
 (0)