]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix from SF bug #541980 (Jacques A. Vidrine).
authorGuido van Rossum <guido@python.org>
Mon, 15 Apr 2002 00:25:01 +0000 (00:25 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 15 Apr 2002 00:25:01 +0000 (00:25 +0000)
When os.stat() for a file raises OSError, turn it into IOError per
documentation.

Bugfix candidate.

Lib/urllib.py

index 2d53c125885205b93e8dbe693a9b1d685a27d4b2..50bed84ee4f29e4e126322158d9d554fc9d9fbac 100644 (file)
@@ -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]