diff options
author | Robey Pointer <robey@lag.net> | 2007-12-30 16:32:59 -0800 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2007-12-30 16:32:59 -0800 |
commit | d70878831c67c3b2d76ab304edadfaed3cfbb980 (patch) | |
tree | 26601b6451bd5fc8d61501fa5181baa5c6c00df6 | |
parent | a3128c63de7fc1aaeb44c455495accd3149a773c (diff) |
[project @ robey@lag.net-20071231003259-xwwescnkvb3e6vxc]
be more explicit about setting buffering options, and make the default
be "unbuffered", because with buffering on, writes are buffered, which can
be very confusing over ssh and usually not what you want.
-rw-r--r-- | paramiko/file.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/paramiko/file.py b/paramiko/file.py index c5ec5c47..7db44015 100644 --- a/paramiko/file.py +++ b/paramiko/file.py @@ -392,6 +392,12 @@ class BufferedFile (object): """ Subclasses call this method to initialize the BufferedFile. """ + # set bufsize in any event, because it's used for readline(). + self._bufsize = self._DEFAULT_BUFSIZE + if bufsize < 0: + # do no buffering by default, because otherwise writes will get + # buffered in a way that will probably confuse people. + bufsize = 0 if bufsize == 1: # apparently, line buffering only affects writes. reads are only # buffered if you call readline (directly or indirectly: iterating @@ -400,6 +406,11 @@ class BufferedFile (object): elif bufsize > 1: self._bufsize = bufsize self._flags |= self.FLAG_BUFFERED + self._flags &= ~self.FLAG_LINE_BUFFERED + elif bufsize == 0: + # unbuffered + self._flags &= ~(self.FLAG_BUFFERED | self.FLAG_LINE_BUFFERED) + if ('r' in mode) or ('+' in mode): self._flags |= self.FLAG_READ if ('w' in mode) or ('+' in mode): |