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

discontinue readavailable() #7478

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -473,3 +473,12 @@ scale!{T<:Base.LinAlg.BlasReal}(X::Array{T}, s::Complex) = error("scale!: Cannot

@deprecate which(f::Callable, args...) @which f(args...)
@deprecate rmdir rm

function readavailable(this::AsyncStream)
depwarn("readavailable() is discontinued. please choose from the alternative I/O functions, such as readall(), readbytes(), nb_available(), and !eof(), depending on your intended usage", :readavailable)
buf = this.buffer
@assert buf.seekable == false
wait_readnb(this,1)
takebuf_string(buf)
end

9 changes: 1 addition & 8 deletions base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,10 @@ function _uv_hook_readcb(stream::AsyncStream, nread::Int, base::Ptr{Void}, len::
else
if isa(stream,TTY)
stream.status = StatusEOF
notify(stream.closenotify)
Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a separate bugfix for the readall function, which needs to be committed separately if Jeff refuses to merge this pull request

else
close(stream)
end
notify(stream.readnotify)
end
else
notify_filled(stream.buffer, nread, base, len)
Expand Down Expand Up @@ -697,13 +697,6 @@ readline(this::AsyncStream) = readuntil(this, '\n')

readline() = readline(STDIN)

function readavailable(this::AsyncStream)
buf = this.buffer
@assert buf.seekable == false
wait_readnb(this,1)
takebuf_string(buf)
end

function readuntil(this::AsyncStream,c::Uint8)
buf = this.buffer
@assert buf.seekable == false
Expand Down
4 changes: 0 additions & 4 deletions doc/stdlib/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1727,10 +1727,6 @@ I/O

Create a PipeBuffer to operate on a data vector, optionally specifying a size beyond which the underlying Array may not be grown.

.. function:: readavailable(stream)

Read all available data on the stream, blocking the task only if no data is available.

.. function:: stat(file)

Returns a structure whose fields contain information about the file. The fields of the structure are:
Expand Down
5 changes: 2 additions & 3 deletions test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ write(master,"1\nquit()\n")

wait(p)

output = readavailable(master)
ccall(:close,Cint,(Cint,),fds)
output = readall(master)
@test output == "julia> 1\r\nquit()\r\n1\r\n\r\njulia> "

close(master)
ccall(:close,Cint,(Cint,),fds)

end

Expand Down