mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-10 21:17:16 +08:00
[extractor/common] Ensure response handle is not prematurely closed before it can be read if it matches expected_status (resolves #17195)
This commit is contained in:
parent
9e351ab71e
commit
43403f2c0d
@ -605,6 +605,11 @@ class InfoExtractor(object):
|
|||||||
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
||||||
if isinstance(err, compat_urllib_error.HTTPError):
|
if isinstance(err, compat_urllib_error.HTTPError):
|
||||||
if self.__can_accept_status_code(err, expected_status):
|
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
|
return err.fp
|
||||||
|
|
||||||
if errnote is False:
|
if errnote is False:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user