summaryrefslogtreecommitdiffstats
path: root/Lib/ftplib.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2005-08-24 04:47:05 (GMT)
committerRaymond Hettinger <python@rcn.com>2005-08-24 04:47:05 (GMT)
commit6f9e3ca5f09ec439cad2355d33b8e50ef7f6e034 (patch)
tree0dac79723af006134fbfb8f24cf82ce4c7961a07 /Lib/ftplib.py
parentd2b70913fdb5b44d7d3471cbb22929364be5b938 (diff)
downloadcpython-6f9e3ca5f09ec439cad2355d33b8e50ef7f6e034.zip
cpython-6f9e3ca5f09ec439cad2355d33b8e50ef7f6e034.tar.gz
cpython-6f9e3ca5f09ec439cad2355d33b8e50ef7f6e034.tar.bz2
Backport 1.74
Diffstat (limited to 'Lib/ftplib.py')
-rw-r--r--Lib/ftplib.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index 9486918..937ee4e 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -208,13 +208,13 @@ class FTP:
if self.debugging: print '*resp*', self.sanitize(resp)
self.lastresp = resp[:3]
c = resp[:1]
+ if c in ('1', '2', '3'):
+ return resp
if c == '4':
raise error_temp, resp
if c == '5':
raise error_perm, resp
- if c not in '123':
- raise error_proto, resp
- return resp
+ raise error_proto, resp
def voidresp(self):
"""Expect a response beginning with '2'."""
@@ -582,17 +582,17 @@ def parse229(resp, peer):
Raises error_proto if it does not contain '(|||port|)'
Return ('host.addr.as.numbers', port#) tuple.'''
- if resp[:3] <> '229':
+ if resp[:3] != '229':
raise error_reply, resp
left = resp.find('(')
if left < 0: raise error_proto, resp
right = resp.find(')', left + 1)
if right < 0:
raise error_proto, resp # should contain '(|||port|)'
- if resp[left + 1] <> resp[right - 1]:
+ if resp[left + 1] != resp[right - 1]:
raise error_proto, resp
parts = resp[left + 1:right].split(resp[left+1])
- if len(parts) <> 5:
+ if len(parts) != 5:
raise error_proto, resp
host = peer[0]
port = int(parts[3])
@@ -755,7 +755,16 @@ class Netrc:
def test():
'''Test program.
- Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...'''
+ Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...
+
+ -d dir
+ -l list
+ -p password
+ '''
+
+ if len(sys.argv) < 2:
+ print test.__doc__
+ sys.exit(0)
debugging = 0
rcfile = None