diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2011-10-23 20:11:00 (GMT) |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2011-10-23 20:11:00 (GMT) |
commit | 2bb96f593a067dafc7f02fef659ff22994b83399 (patch) | |
tree | b2b2acc64f5e4e6da3d98541544c72b2a439e98a /Lib/ftplib.py | |
parent | 8d48b43ea9abe494527acea05dcd6b8d067278ea (diff) | |
download | cpython-2bb96f593a067dafc7f02fef659ff22994b83399.zip cpython-2bb96f593a067dafc7f02fef659ff22994b83399.tar.gz cpython-2bb96f593a067dafc7f02fef659ff22994b83399.tar.bz2 |
Cleanup code: remove int/long idioms and simplify a while statement.
Diffstat (limited to 'Lib/ftplib.py')
-rw-r--r-- | Lib/ftplib.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py index f87f690..b470216 100644 --- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -175,10 +175,8 @@ class FTP: # Internal: "sanitize" a string for printing def sanitize(self, s): - if s[:5] == 'pass ' or s[:5] == 'PASS ': - i = len(s) - while i > 5 and s[i-1] in {'\r', '\n'}: - i = i-1 + if s[:5] in {'pass ', 'PASS '}: + i = len(s.rstrip('\r\n')) s = s[:5] + '*'*(i-5) + s[i:] return repr(s) @@ -596,10 +594,7 @@ class FTP: resp = self.sendcmd('SIZE ' + filename) if resp[:3] == '213': s = resp[3:].strip() - try: - return int(s) - except (OverflowError, ValueError): - return int(s) + return int(s) def mkd(self, dirname): '''Make a directory, return its full pathname.''' @@ -861,11 +856,7 @@ def parse150(resp): m = _150_re.match(resp) if not m: return None - s = m.group(1) - try: - return int(s) - except (OverflowError, ValueError): - return int(s) + return int(m.group(1)) _227_re = None |