aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/downloader
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2020-11-21 04:22:21 +0700
committerSergey M․ <dstftw@gmail.com>2020-11-21 04:22:21 +0700
commita7e0531999fa3a7fef542942aaad8c55e22adec5 (patch)
treeef803438ce2631116f498db4c5d642c02b1a910a /youtube_dl/downloader
parentab0eda99e1d1c6cd6aa697f4931c439bec350bd0 (diff)
[downloader/http] Fix crash during urlopen caused by missing reason of URLError
Diffstat (limited to 'youtube_dl/downloader')
-rw-r--r--youtube_dl/downloader/http.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/youtube_dl/downloader/http.py b/youtube_dl/downloader/http.py
index 96379caf1..d8ac41dcc 100644
--- a/youtube_dl/downloader/http.py
+++ b/youtube_dl/downloader/http.py
@@ -109,7 +109,9 @@ class HttpFD(FileDownloader):
try:
ctx.data = self.ydl.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