Skip to content

make write(io, Any[...]) an error #6466

@mbauman

Description

@mbauman

I noticed this with IOBuffer, but it looks like IOStream, AsyncStream, and File all have the same issue. In each of their read!{T,N}(::IO, a::Array{T,N}) methods, they assume that the number of bytes to read is length(a)*sizeof(T). This is not true for Char:

julia> buf = IOBuffer("abcdefghijklmnop");

julia> read(buf, Char)
'a'

julia> read(buf, Char, 2) # dispatches to read!(IOBuffer, Array{Char,1})
2-element Array{Char,1}:
 '\U65646362'
 '\U69686766'

For IOBuffer, I think the specialization could simply be removed (albeit perhaps at a small performance loss). The others, however, are trickier — File performance is much more critical and the Async/IOStream ones need to know how many bytes to wait for.

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorioInvolving the I/O subsystem: libuv, read, write, etc.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions