Commit a2da3052 authored by Guido van Rossum's avatar Guido van Rossum

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

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

Bugfix candidate.
parent f90d5292
...@@ -413,7 +413,10 @@ class URLopener: ...@@ -413,7 +413,10 @@ class URLopener:
import mimetypes, mimetools, rfc822, StringIO import mimetypes, mimetools, rfc822, StringIO
host, file = splithost(url) host, file = splithost(url)
localname = url2pathname(file) localname = url2pathname(file)
try:
stats = os.stat(localname) stats = os.stat(localname)
except OSError, e:
raise IOError(e.errno, e.strerror, e.filename)
size = stats.st_size size = stats.st_size
modified = rfc822.formatdate(stats.st_mtime) modified = rfc822.formatdate(stats.st_mtime)
mtype = mimetypes.guess_type(url)[0] mtype = mimetypes.guess_type(url)[0]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment