summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-04-15 00:25:01 (GMT)
committerGuido van Rossum <guido@python.org>2002-04-15 00:25:01 (GMT)
commita2da305211c23fc7090f95540cc1b793e474f9c1 (patch)
tree55434b3a87cae2cf021036f87b9e1bca52d6b89d /Lib
parentf90d5292298cbaa114c4a1d000e7d8e946ca65b3 (diff)
downloadcpython-a2da305211c23fc7090f95540cc1b793e474f9c1.zip
cpython-a2da305211c23fc7090f95540cc1b793e474f9c1.tar.gz
cpython-a2da305211c23fc7090f95540cc1b793e474f9c1.tar.bz2
Fix from SF bug #541980 (Jacques A. Vidrine).
When os.stat() for a file raises OSError, turn it into IOError per documentation. Bugfix candidate.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/urllib.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 2d53c12..50bed84 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -413,7 +413,10 @@ class URLopener:
import mimetypes, mimetools, rfc822, StringIO
host, file = splithost(url)
localname = url2pathname(file)
- stats = os.stat(localname)
+ try:
+ stats = os.stat(localname)
+ except OSError, e:
+ raise IOError(e.errno, e.strerror, e.filename)
size = stats.st_size
modified = rfc822.formatdate(stats.st_mtime)
mtype = mimetypes.guess_type(url)[0]