From bb0f8c2607eb0cfb1b21e1733a2d70a17f568458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=3D=3FUTF-8=3Fq=3FSergey=3D20M=3DE2=3D80=3DA4=3F=3D?= Date: Fri, 26 Feb 2021 14:27:49 +0100 Subject: [PATCH] =?UTF-8?q?[downloader/http]=20Fix=20crash=20during=20urlo?= =?UTF-8?q?pen=20caused=20by=20missing=20reason=20o=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …f URLError --- haruhi_dl/downloader/http.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/haruhi_dl/downloader/http.py b/haruhi_dl/downloader/http.py index c9c908b34..6d3d8f1e5 100644 --- a/haruhi_dl/downloader/http.py +++ b/haruhi_dl/downloader/http.py @@ -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