Commit be17a117 authored by Benjamin Peterson's avatar Benjamin Peterson

Merged revisions 66634 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r66634 | benjamin.peterson | 2008-09-26 21:49:54 -0500 (Fri, 26 Sep 2008) | 7 lines

  give ftplib a real test suite

  A asyncore based mock ftp server is used to test the protocol.
  This is all thanks to Giampaolo Rodola #3939

  (Barry gave me permission to do this before final on IRC.)
........
parent f2e93680
......@@ -71,6 +71,7 @@ all_errors = (Error, IOError, EOFError)
# Line terminators (we always output CRLF, but accept any of CRLF, CR, LF)
CRLF = '\r\n'
B_CRLF = b'\r\n'
# The class itself
class FTP:
......@@ -472,9 +473,9 @@ class FTP:
while 1:
buf = fp.readline()
if not buf: break
if buf[-2:] != CRLF:
if buf[-1] in CRLF: buf = buf[:-1]
buf = buf + 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()
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment