diff options
author | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-08-04 10:12:00 (GMT) |
---|---|---|
committer | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-08-04 10:12:00 (GMT) |
commit | b939235c6aa82ec447c2948851396e4ec781bf5e (patch) | |
tree | be07155da73cce90da0c0291c77944f4e97d24e8 /Lib/ftplib.py | |
parent | b5c23761d3ef63d596d5f0c1f1e510b30fdf21e1 (diff) | |
download | cpython-b939235c6aa82ec447c2948851396e4ec781bf5e.zip cpython-b939235c6aa82ec447c2948851396e4ec781bf5e.tar.gz cpython-b939235c6aa82ec447c2948851396e4ec781bf5e.tar.bz2 |
fix issue #6822: ftplib's storline method doesn't work with text files
Diffstat (limited to 'Lib/ftplib.py')
-rw-r--r-- | Lib/ftplib.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py index b593fa1..ada7475 100644 --- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -493,9 +493,15 @@ class FTP: while 1: buf = fp.readline() if not buf: break - if buf[-2:] != B_CRLF: - if buf[-1] in B_CRLF: buf = buf[:-1] - buf = buf + B_CRLF + if isinstance(buf, str): + if not buf.endswith(CRLF): + if buf[-1] in CRLF: buf = buf[:-1] + buf = buf + CRLF + buf = bytes(buf, self.encoding) + else: + if not buf.endswith(B_CRLF): + if buf[-1:] in B_CRLF: buf = buf[:-1] + buf = buf + B_CRLF conn.sendall(buf) if callback: callback(buf) conn.close() @@ -771,9 +777,15 @@ else: while 1: buf = fp.readline() if not buf: break - if buf[-2:] != B_CRLF: - if buf[-1] in B_CRLF: buf = buf[:-1] - buf = buf + B_CRLF + if isinstance(buf, str): + if not buf.endswith(CRLF): + if buf[-1] in CRLF: buf = buf[:-1] + buf = buf + CRLF + buf = bytes(buf, self.encoding) + else: + if not buf.endswith(B_CRLF): + if buf[-1:] in B_CRLF: buf = buf[:-1] + buf = buf + B_CRLF conn.sendall(buf) if callback: callback(buf) # shutdown ssl layer @@ -783,6 +795,7 @@ else: conn.close() return self.voidresp() + __all__.append('FTP_TLS') all_errors = (Error, IOError, EOFError, ssl.SSLError) |