Fix from SF bug #541980 (Jacques A. Vidrine).

When os.stat() for a file raises OSError, turn it into IOError per
documentation.

Bugfix candidate.
This commit is contained in:
Guido van Rossum 2002-04-15 00:25:01 +00:00
parent f90d529229
commit a2da305211
1 changed files with 4 additions and 1 deletions

View 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]