Skip to content

Commit ce1277f

Browse files
vchuravyvtjnash
authored andcommitted
Use require(pkgid, ...) instead of relative require (#29770)
Co-authored-by: Jameson Nash <[email protected]> (cherry picked from commit 6ae6551)
1 parent 1536425 commit ce1277f

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

base/client.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,11 @@ function exec_options(opts)
226226
# Load Distributed module only if any of the Distributed options have been specified.
227227
distributed_mode = (opts.worker == 1) || (opts.nprocs > 0) || (opts.machine_file != C_NULL)
228228
if distributed_mode
229-
Core.eval(Main, :(using Distributed))
229+
let Distributed = require(PkgId(UUID((0x8ba89e20_285c_5b6f, 0x9357_94700520ee1b)), "Distributed"))
230+
Core.eval(Main, :(const Distributed = $Distributed))
231+
Core.eval(Main, :(using .Distributed))
232+
end
233+
230234
invokelatest(Main.Distributed.process_opts, opts)
231235
end
232236

base/stream.jl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ unlock(s::LibuvStream) = unlock(s.lock)
216216
rawhandle(stream::LibuvStream) = stream.handle
217217
unsafe_convert(::Type{Ptr{Cvoid}}, s::Union{LibuvStream, LibuvServer}) = s.handle
218218

219-
const Sockets_mod = Ref{Module}()
220-
221219
function init_stdio(handle::Ptr{Cvoid})
222220
t = ccall(:jl_uv_handle_type, Int32, (Ptr{Cvoid},), handle)
223221
if t == UV_FILE
@@ -233,10 +231,8 @@ function init_stdio(handle::Ptr{Cvoid})
233231
elseif t == UV_TTY
234232
return TTY(handle, StatusOpen)
235233
elseif t == UV_TCP
236-
if !isassigned(Sockets_mod)
237-
Sockets_mod[] = Base.require(Base, :Sockets)
238-
end
239-
return Sockets_mod[].TCPSocket(handle, StatusOpen)
234+
Sockets = require(PkgId(UUID((0x6462fe0b_24de_5631, 0x8697_dd941f90decc)), "Sockets"))
235+
return Sockets.TCPSocket(handle, StatusOpen)
240236
elseif t == UV_NAMED_PIPE
241237
return PipeEndpoint(handle, StatusOpen)
242238
else

stdlib/Sockets/test/runtests.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,21 @@ end
433433
end
434434
end
435435

436+
@static if !Sys.iswindows()
437+
# Issue #29234
438+
@testset "TCPSocket stdin" begin
439+
let addr = Sockets.InetAddr(ip"127.0.0.1", 4455)
440+
srv = listen(addr)
441+
s = connect(addr)
442+
443+
@test success(pipeline(`$(Base.julia_cmd()) -e "exit()" -i`, stdin=s))
444+
445+
close(s)
446+
close(srv)
447+
end
448+
end
449+
end
450+
436451
# Issues #18818 and #24169
437452
mutable struct RLimit
438453
cur::Int64

0 commit comments

Comments
 (0)