summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-11-12 18:48:13 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-11-12 18:48:13 (GMT)
commit36cbc08f3fd57b41bcde8c1ec19d79e59d95f9ca (patch)
tree41f9fc3c07a95a23c1469281ce22fd1b0abec562
parent056dac1bcfb9aa09e156cb79b111d73ac9a44ec1 (diff)
downloadcpython-36cbc08f3fd57b41bcde8c1ec19d79e59d95f9ca.zip
cpython-36cbc08f3fd57b41bcde8c1ec19d79e59d95f9ca.tar.gz
cpython-36cbc08f3fd57b41bcde8c1ec19d79e59d95f9ca.tar.bz2
Patch #1359217: Ignore 2xx response before 150 response.
Will backport to 2.5.
-rw-r--r--Lib/ftplib.py11
-rw-r--r--Misc/NEWS3
2 files changed, 14 insertions, 0 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index 937ee4e..9cb67dd 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -325,6 +325,14 @@ class FTP:
if rest is not None:
self.sendcmd("REST %s" % rest)
resp = self.sendcmd(cmd)
+ # Some servers apparently send a 200 reply to
+ # a LIST or STOR command, before the 150 reply
+ # (and way before the 226 reply). This seems to
+ # be in violation of the protocol (which only allows
+ # 1xx or error messages for LIST), so we just discard
+ # this response.
+ if resp[0] == '2':
+ resp = self.getresp()
if resp[0] != '1':
raise error_reply, resp
else:
@@ -332,6 +340,9 @@ class FTP:
if rest is not None:
self.sendcmd("REST %s" % rest)
resp = self.sendcmd(cmd)
+ # See above.
+ if resp[0] == '2':
+ resp = self.getresp()
if resp[0] != '1':
raise error_reply, resp
conn, sockaddr = sock.accept()
diff --git a/Misc/NEWS b/Misc/NEWS
index bd9d264..85e231d 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -98,6 +98,9 @@ Core and builtins
Library
-------
+- Patch #1359217: Process 2xx response in an ftplib transfer
+ that precedes an 1xx response.
+
- Patch #1355023: support whence argument for GzipFile.seek.
- Patch #1065257: Support passing open files as body in