summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-06-06 17:44:07 (GMT)
committerGuido van Rossum <guido@python.org>1997-06-06 17:44:07 (GMT)
commit2966b322055158184eebc72bb892ef2ccc42f0d2 (patch)
treec54885a1190eb242438ca0ce8fa4d4ac0f15fe71
parent0318fd6050fb5914fdcc1fa88cce80251481d8cf (diff)
downloadcpython-2966b322055158184eebc72bb892ef2ccc42f0d2.zip
cpython-2966b322055158184eebc72bb892ef2ccc42f0d2.tar.gz
cpython-2966b322055158184eebc72bb892ef2ccc42f0d2.tar.bz2
Catch *all* errors that ftplib can raise (ftplib.all_errors) rather
than just the four. Also folded some long lines.
-rw-r--r--Lib/urllib.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 390dd63..173f83b 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -288,12 +288,16 @@ class URLopener:
def open_local_file(self, url):
host, file = splithost(url)
if not host:
- return addinfourl(open(url2pathname(file), 'rb'), noheaders(), 'file:'+file)
+ return addinfourl(
+ open(url2pathname(file), 'rb'),
+ noheaders(), 'file:'+file)
host, port = splitport(host)
if not port and socket.gethostbyname(host) in (
localhost(), thishost()):
file = unquote(file)
- return addinfourl(open(url2pathname(file), 'rb'), noheaders(), 'file:'+file)
+ return addinfourl(
+ open(url2pathname(file), 'rb'),
+ noheaders(), 'file:'+file)
raise IOError, ('local file error', 'not on local host')
# Use FTP protocol
@@ -325,8 +329,9 @@ class URLopener:
if string.lower(attr) == 'type' and \
value in ('a', 'A', 'i', 'I', 'd', 'D'):
type = string.upper(value)
- return addinfourl(self.ftpcache[key].retrfile(file, type),
- noheaders(), self.openedurl)
+ return addinfourl(
+ self.ftpcache[key].retrfile(file, type),
+ noheaders(), self.openedurl)
except ftperrors(), msg:
raise IOError, ('ftp error', msg), sys.exc_traceback
@@ -443,10 +448,7 @@ def ftperrors():
global _ftperrors
if not _ftperrors:
import ftplib
- _ftperrors = (ftplib.error_reply,
- ftplib.error_temp,
- ftplib.error_perm,
- ftplib.error_proto)
+ _ftperrors = ftplib.all_errors
return _ftperrors
# Return an empty mimetools.Message object