From 5662ca0d32556552f27558107a1828c3e348762d Mon Sep 17 00:00:00 2001 From: Anthony Baxter Date: Thu, 18 Apr 2002 02:19:19 +0000 Subject: [PATCH] backport gvanrossum's patch Fix from SF bug #541980 (Jacques A. Vidrine). When os.stat() for a file raises OSError, turn it into IOError per documentation. --- Lib/urllib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/urllib.py b/Lib/urllib.py index 002ac515630a..8188d4806f59 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -409,7 +409,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[stat.ST_SIZE] modified = rfc822.formatdate(stats[stat.ST_MTIME]) mtype = mimetypes.guess_type(url)[0] -- 2.47.3