Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: fix reading LibuvStream into array #56092

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

stream: fix reading LibuvStream into array #56092

wants to merge 1 commit into from

Conversation

vtjnash
Copy link
Sponsor Member

@vtjnash vtjnash commented Oct 10, 2024

Adds a new abstraction take!(dst::Array{T,N}, src::Array{T,N}) for doing an efficient copyto! equivalent. Previously it was assumed that compact did this automatically, which wasn't a great assumption.

Fixes #56078

Adds a new abstraction `take!(::Array{T,N}, ::Array{T,N})` for doing an
efficient `copyto!` equivalent. Previously it was assumed that `compact`
did this automatically, which wasn't a great assumption.

Fixes #56078
@vtjnash vtjnash added io Involving the I/O subsystem: libuv, read, write, etc. backport 1.11 Change should be backported to release-1.11 labels Oct 10, 2024
@giordano giordano added the needs tests Unit tests are required for this change label Oct 10, 2024
@nhz2
Copy link
Contributor

nhz2 commented Oct 10, 2024

This is still broken.

readbytes! is documented to never decrease the size of the input vector, but in this example, it gets changed from 1024 to 10.

function mwe(filepath, nb, max_nb)
    write(filepath, ones(UInt8, nb))
    p = open(`cat $filepath`; read=true)
    b = Vector{UInt8}(undef, 1024)
    nr = readbytes!(p, b, max_nb)
    return nr, b
end
nr, b = mwe(tempname(), 10, 10000)
(10, UInt8[0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.11 Change should be backported to release-1.11 io Involving the I/O subsystem: libuv, read, write, etc. needs tests Unit tests are required for this change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

readbytes!(::Process, ::Vector{UInt8}, ::Int) does not read bytes on 1.11
3 participants