[downloader/http] Fix crash during urlopen caused by missing reason o…

…f URLError
This commit is contained in:
=?UTF-8?q?Sergey=20M=E2=80=A4?= 2021-02-26 14:27:49 +01:00 committed by Dominika
parent 1250d58b96
commit 21c9c8293f

View file

@ -109,7 +109,9 @@ class HttpFD(FileDownloader):
try:
ctx.data = self.hdl.urlopen(request)
except (compat_urllib_error.URLError, ) as err:
if isinstance(err.reason, socket.timeout):
# reason may not be available, e.g. for urllib2.HTTPError on python 2.6
reason = getattr(err, 'reason', None)
if isinstance(reason, socket.timeout):
raise RetryDownload(err)
raise err
# When trying to resume, Content-Range HTTP header of response has to be checked