Reword docs/changelog re #315

This commit is contained in:
Jeff Forcier 2014-04-24 09:33:38 -07:00
parent 3fce8abf68
commit 5636381591
2 changed files with 22 additions and 17 deletions

View File

@ -124,15 +124,14 @@ class BufferedFile (object):
file first). If the ``size`` argument is negative or omitted, read all file first). If the ``size`` argument is negative or omitted, read all
the remaining data in the file. the remaining data in the file.
`'b' mode flag is ignored (self.FLAG_BINARY in self._flags), because ``'b'`` mode flag is ignored (``self.FLAG_BINARY`` in ``self._flags``),
SSH treats all files as binary, since we have no idea what encoding because SSH treats all files as binary, since we have no idea what
the file is in, or even if the file is text data. encoding the file is in, or even if the file is text data.
:param int size: maximum number of bytes to read :param int size: maximum number of bytes to read
:return: :return:
data read from the file (as bytes ), or an empty string data read from the file (as bytes), or an empty string if EOF was
if EOF was encountered immediately encountered immediately
""" """
if self._closed: if self._closed:
raise IOError('File is closed') raise IOError('File is closed')
@ -193,10 +192,10 @@ class BufferedFile (object):
:return: :return:
next line of the file, or an empty string if the end of the next line of the file, or an empty string if the end of the
file has been reached. file has been reached.
If the file was opened in binary 'b' mode: bytes are returned
Else: the encoding of the file is assumed to be utf-8 (default If the file was opened in binary (``'b'``) mode: bytes are returned
encoding used by paramiko.py3compat.u) and character strings Else: the encoding of the file is assumed to be UTF-8 and character
(`str`) are returned strings (`str`) are returned
""" """
# it's almost silly how complex this function is. # it's almost silly how complex this function is.
if self._closed: if self._closed:

View File

@ -2,13 +2,19 @@
Changelog Changelog
========= =========
* :bug: BufferedFile.read() now returns byte strings instead of text strings * :bug:`-` `paramiko.file.BufferedFile.read` incorrectly returned text strings
It is the right thing to do since we have no idea what encoding the file after the Python 3 migration, despite bytes being more appropriate for file
is in, or even if the file is text data. BufferedFile.readline() is contents (which may be binary or of an unknown encoding.) This has been
unchanged and returns text strings assuming the file is utf-8 encoded. addressed.
This should fix the following issue:
http://comments.gmane.org/gmane.comp.sysutils.backup.obnam/252 .. note::
Thanks Antoine Brenner `paramiko.file.BufferedFile.readline` continues to return strings, not
bytes, as "lines" only make sense for textual data. It assumes UTF-8 by
default.
This should fix `this issue raised on the Obnam mailing list
<http://comments.gmane.org/gmane.comp.sysutils.backup.obnam/252>`_. Thanks
to Antoine Brenner for the patch.
* :bug:`-` Added self.args for exception classes. Used for unpickling. Related * :bug:`-` Added self.args for exception classes. Used for unpickling. Related
to (`Fabric #986 <https://github.com/fabric/fabric/issues/986>`_, `Fabric to (`Fabric #986 <https://github.com/fabric/fabric/issues/986>`_, `Fabric
#714 <https://github.com/fabric/fabric/issues/714>`_). Thanks to Alex #714 <https://github.com/fabric/fabric/issues/714>`_). Thanks to Alex