From: Guido van Rossum Date: Mon, 15 Apr 2002 00:25:01 +0000 (+0000) Subject: Fix from SF bug #541980 (Jacques A. Vidrine). X-Git-Tag: v2.3c1~5969 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a2da305211c23fc7090f95540cc1b793e474f9c1;p=thirdparty%2FPython%2Fcpython.git Fix from SF bug #541980 (Jacques A. Vidrine). When os.stat() for a file raises OSError, turn it into IOError per documentation. Bugfix candidate. --- diff --git a/Lib/urllib.py b/Lib/urllib.py index 2d53c1258852..50bed84ee4f2 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]