mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Issue #10836: Fix exception raised when file not found in urlretrieve
This commit is contained in:
parent
8a915499f6
commit
f577686fd3
3 changed files with 10 additions and 2 deletions
|
@ -268,6 +268,11 @@ Content-Type: text/html; charset=iso-8859-1
|
||||||
finally:
|
finally:
|
||||||
self.unfakehttp()
|
self.unfakehttp()
|
||||||
|
|
||||||
|
def test_missing_localfile(self):
|
||||||
|
# Test for #10836
|
||||||
|
with self.assertRaises(urllib.error.URLError):
|
||||||
|
urlopen('file://localhost/a/file/which/doesnot/exists.py')
|
||||||
|
|
||||||
def test_userpass_inurl(self):
|
def test_userpass_inurl(self):
|
||||||
self.fakehttp(b"HTTP/1.0 200 OK\r\n\r\nHello!")
|
self.fakehttp(b"HTTP/1.0 200 OK\r\n\r\nHello!")
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1664,7 +1664,7 @@ class URLopener:
|
||||||
return getattr(self, name)(url)
|
return getattr(self, name)(url)
|
||||||
else:
|
else:
|
||||||
return getattr(self, name)(url, data)
|
return getattr(self, name)(url, data)
|
||||||
except HTTPError:
|
except (HTTPError, URLError):
|
||||||
raise
|
raise
|
||||||
except socket.error as msg:
|
except socket.error as msg:
|
||||||
raise IOError('socket error', msg).with_traceback(sys.exc_info()[2])
|
raise IOError('socket error', msg).with_traceback(sys.exc_info()[2])
|
||||||
|
@ -1891,7 +1891,7 @@ class URLopener:
|
||||||
try:
|
try:
|
||||||
stats = os.stat(localname)
|
stats = os.stat(localname)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise URLError(e.errno, e.strerror, e.filename)
|
raise URLError(e.strerror, e.filename)
|
||||||
size = stats.st_size
|
size = stats.st_size
|
||||||
modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
|
modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
|
||||||
mtype = mimetypes.guess_type(url)[0]
|
mtype = mimetypes.guess_type(url)[0]
|
||||||
|
|
|
@ -59,6 +59,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #10836: Fix exception raised when file not found in urlretrieve
|
||||||
|
Initial patch by Ezio Melotti.
|
||||||
|
|
||||||
- Issue #14398: Fix size truncation and overflow bugs in the bz2 module.
|
- Issue #14398: Fix size truncation and overflow bugs in the bz2 module.
|
||||||
|
|
||||||
- Issue #12692: Fix resource leak in urllib.request when talking to an HTTP
|
- Issue #12692: Fix resource leak in urllib.request when talking to an HTTP
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue