diff --git a/Lib/urllib.py b/Lib/urllib.py index 2d53c125885..50bed84ee4f 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]