summaryrefslogtreecommitdiffstats
path: root/Lib/ftplib.py
diff options
context:
space:
mode:
authorGiampaolo RodolĂ  <g.rodola@gmail.com>2010-08-04 10:36:18 (GMT)
committerGiampaolo RodolĂ  <g.rodola@gmail.com>2010-08-04 10:36:18 (GMT)
commitf96482e91a1e1806a3d17b18a1307bbd67d30c15 (patch)
tree0a803ada36625a91dac3434db0f0fe33bfee8440 /Lib/ftplib.py
parent226e945fe5da51658017e0d216f1d4ddae645fce (diff)
downloadcpython-f96482e91a1e1806a3d17b18a1307bbd67d30c15.zip
cpython-f96482e91a1e1806a3d17b18a1307bbd67d30c15.tar.gz
cpython-f96482e91a1e1806a3d17b18a1307bbd67d30c15.tar.bz2
as per discussion with antoine revert changes made in 83708 as the user useing ftplib's readline methods is supposed to always use a binary file
Diffstat (limited to 'Lib/ftplib.py')
-rw-r--r--Lib/ftplib.py25
1 files changed, 6 insertions, 19 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index ada7475..b593fa1 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -493,15 +493,9 @@ class FTP:
while 1:
buf = fp.readline()
if not buf: break
- 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
+ if buf[-2:] != B_CRLF:
+ if buf[-1] in B_CRLF: buf = buf[:-1]
+ buf = buf + B_CRLF
conn.sendall(buf)
if callback: callback(buf)
conn.close()
@@ -777,15 +771,9 @@ else:
while 1:
buf = fp.readline()
if not buf: break
- 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
+ if buf[-2:] != 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
@@ -795,7 +783,6 @@ else:
conn.close()
return self.voidresp()
-
__all__.append('FTP_TLS')
all_errors = (Error, IOError, EOFError, ssl.SSLError)