Skip to content

Commit

Permalink
Merge pull request #272 from cstjean/pull-request/31a80a21
Browse files Browse the repository at this point in the history
Fix #271
  • Loading branch information
cstjean committed May 17, 2016
2 parents 71495c1 + a551fa2 commit 802a18d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ function pyio_initialize()
closed.get(self) = @with_ioraise(!isopen(pyio_jl(self)))
encoding.get(self) = "UTF-8"
fileno(self) = @with_ioraise(fd(pyio_jl(self)))
flush(self) = @with_ioraise(flush(pyio_jl(self)))
flush(self) = begin
@with_ioraise begin
io = pyio_jl(self)
if method_exists(flush, Tuple{typeof(io)})
flush(io)
end
end
end
isatty(self) = isa(pyio_jl(self), Base.TTY)
readable(self) = isreadable(pyio_jl(self))
writable(self) = iswritable(pyio_jl(self))
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ let buf = IOBuffer(false, true), obuf = PyObject(buf)
@test !obuf[:readable]()
@test obuf[:seekable]()
obuf[:write](pyutf8("hello"))
obuf[:flush]() # should be a no-op, since there's no flushing IOBuffer
@test position(buf) == obuf[:tell]() == 5
let p = obuf[:seek](-2, 1)
@test p == position(buf) == 3
Expand Down

0 comments on commit 802a18d

Please sign in to comment.