diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2014-08-25 22:08:26 -0700 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2014-08-25 22:08:26 -0700 |
commit | ce1ec358abbd1726f39df9b19d6e4e681819abb9 (patch) | |
tree | c424bdf57935a896caf72f1fe029f39483e8d926 | |
parent | 951faed80b017e553a27c4cb98f210df44341f8f (diff) | |
parent | d05ca17db876055a5f584e720b1b0733116b4365 (diff) |
Merge branch '1.13' into 1.14
Conflicts:
sites/www/changelog.rst
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | paramiko/py3compat.py | 4 | ||||
-rw-r--r-- | sites/www/changelog.rst | 6 | ||||
-rwxr-xr-x | tests/test_file.py | 10 |
4 files changed, 21 insertions, 1 deletions
@@ -35,7 +35,7 @@ Requirements ------------ - Python 2.6 or better <http://www.python.org/> - this includes Python - 3.3 and higher as well. + 3.2 and higher as well. - pycrypto 2.1 or better <https://www.dlitz.net/software/pycrypto/> - ecdsa 0.9 or better <https://pypi.python.org/pypi/ecdsa> diff --git a/paramiko/py3compat.py b/paramiko/py3compat.py index 8842b988..57c096b2 100644 --- a/paramiko/py3compat.py +++ b/paramiko/py3compat.py @@ -39,6 +39,8 @@ if PY2: return s elif isinstance(s, unicode): return s.encode(encoding) + elif isinstance(s, buffer): + return s else: raise TypeError("Expected unicode or bytes, got %r" % s) @@ -49,6 +51,8 @@ if PY2: return s.decode(encoding) elif isinstance(s, unicode): return s + elif isinstance(s, buffer): + return s.decode(encoding) else: raise TypeError("Expected unicode or bytes, got %r" % s) diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index f8a4d2c1..81195a49 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,6 +2,12 @@ Changelog ========= +* :bug:`285` (also :issue:`352`) Update our Python 3 ``b()`` compatibility shim + to handle ``buffer`` objects correctly; this fixes a frequently reported + issue affecting many users, including users of the ``bzr`` software suite. + Thanks to ``@basictheprogram`` for the initial report, Jelmer Vernooij for + the fix and Andrew Starr-Bochicchio & Jeremy T. Bouse (among others) for + discussion & feedback. * :release:`1.14.0 <2014-05-07>` * :release:`1.13.1 <2014-05-07>` * :release:`1.12.4 <2014-05-07>` diff --git a/tests/test_file.py b/tests/test_file.py index c6edd7af..22a34aca 100755 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -23,6 +23,7 @@ Some unit tests for the BufferedFile abstraction. import unittest from paramiko.file import BufferedFile from paramiko.common import linefeed_byte, crlf, cr_byte +import sys class LoopbackFile (BufferedFile): @@ -151,6 +152,15 @@ class BufferedFileTest (unittest.TestCase): b'need to close them again.\n') f.close() + def test_8_buffering(self): + """ + verify that buffered objects can be written + """ + if sys.version_info[0] == 2: + f = LoopbackFile('r+', 16) + f.write(buffer(b'Too small.')) + f.close() + if __name__ == '__main__': from unittest import main main() |