From 43403f2c0d53c87b2d934d6c5d225c1d2ce32089 Mon Sep 17 00:00:00 2001 From: Xiao Di Guan Date: Fri, 10 Aug 2018 12:23:15 +1000 Subject: [PATCH] [extractor/common] Ensure response handle is not prematurely closed before it can be read if it matches expected_status (resolves #17195) --- youtube_dl/extractor/common.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index 2dbf81e6e..420b690af 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -605,6 +605,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 + # introduced in Python 3.4.1. + err.fp._error = err return err.fp if errnote is False: