aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/common.py
diff options
context:
space:
mode:
authorXiao Di Guan <xdg@puxlit.net>2018-11-03 05:18:20 +1100
committerSergey M <dstftw@gmail.com>2018-11-03 01:18:20 +0700
commit95e42d7336d01f505d6551a21df52f3ae234e96b (patch)
tree795dc08fedf4db29ac64a938197bebf7f5f0ebfe /youtube_dl/extractor/common.py
parentcf0db4d99785532d767d0ca1cc029c73d16bb045 (diff)
downloadyoutube-dl-95e42d7336d01f505d6551a21df52f3ae234e96b.tar.xz
[extractor/common] Ensure response handle is not prematurely closed before it can be read if it matches expected_status (resolves #17195, closes #17846, resolves #17447)
Diffstat (limited to 'youtube_dl/extractor/common.py')
-rw-r--r--youtube_dl/extractor/common.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py
index 8452125c8..e5f8136fc 100644
--- a/youtube_dl/extractor/common.py
+++ b/youtube_dl/extractor/common.py
@@ -606,6 +606,11 @@ class InfoExtractor(object):
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
if isinstance(err, compat_urllib_error.HTTPError):
if self.__can_accept_status_code(err, expected_status):
+ # Retain reference to error to prevent file object from
+ # being closed before it can be read. Works around the
+ # effects of <https://bugs.python.org/issue15002>
+ # introduced in Python 3.4.1.
+ err.fp._error = err
return err.fp
if errnote is False: