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

writing to a read-only IOStream should fail #224

Closed
StefanKarpinski opened this issue Oct 16, 2011 · 3 comments
Closed

writing to a read-only IOStream should fail #224

StefanKarpinski opened this issue Oct 16, 2011 · 3 comments
Labels
bug Indicates an unexpected problem or unintended behavior io Involving the I/O subsystem: libuv, read, write, etc.
Milestone

Comments

@StefanKarpinski
Copy link
Member

Likewise, reading from a write-only IOStream should probably fail too.

@ghost ghost assigned JeffBezanson Nov 11, 2011
@staticfloat
Copy link
Member

At the moment, I see the following behavior:

julia> a
2x2 Float64 Array:
 1.0  2.0
 3.0  4.0

julia> f = open("/tmp/jtest", "w")
IOStream(<file /tmp/jtest>)

julia> write(f,a)
0x0000000000000020

julia> position(f)
32

julia> seek(f,0)
true

julia> read(f,Array(Float64,2,2))
read: end of file
 in read at io.jl:241

So reading from a write-only stream seems to fail with an error, however writing to a read-only stream doesn't error out, it only returns zero:

julia> f = open("/tmp/jtest", "r")                                              
IOStream(<file /tmp/jtest>)

julia> read(f,Array(Float64,2,2))                                               
2x2 Float64 Array:
 1.0  2.0
 3.0  4.0

julia> seek(f,0)                                                                
true

julia> write(f,a)
0x0000000000000000

Should these two responses be matched? If so, what should the response be? This is typically the area where exceptions and such come into play in other languages, as it's pretty important to send IO errors and such back up to user flow control. However, you guys may have a different idea as to how this should be handled.

@vtjnash
Copy link
Member

vtjnash commented Feb 1, 2013

possibly similar to #1701 [closed]. what is the thoughts on the I/O system behavior here?

@loladiro this will possibly be relevant to us during libuv File API rewrite

@ViralBShah
Copy link
Member

Seems like you can still write to a read-only IOStream as per the example above.

@Keno Keno closed this as completed in 0d19559 Jul 16, 2013
StefanKarpinski pushed a commit that referenced this issue Feb 8, 2018
* Compat for new unsafe wrapper methods

* Correct version number

* Fix tests

* Avoid method overwrite

* Define pointer_to_string for .3

* Fix pointer aliasing

* Add docs
Keno pushed a commit that referenced this issue Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
Development

No branches or pull requests

5 participants