-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response file object (returned by InfoExtractor._request_webpage
) may be closed for failed requests (matching expected_status
) on Python 3.4.1+
#17195
Comments
I don't see any problem here. By using |
@dstftw, we're not talking about a closed connection here, we're talking about the response body being inaccessible, which defeats the point of So unless you're saying that in usages like |
…efore it can be read if it matches expected_status (resolves ytdl-org#17195)
…efore it can be read if it matches expected_status (resolves ytdl-org#17195)
* 'master' of https://github.com/rg3/youtube-dl: (186 commits) release 2018.11.07 [ChangeLog] Actualize [ci skip] [youtube] Add another JS signature function name regex (closes #18091, closes #18093, closes #18094) [facebook] fix tahoe request(closes #17171) [cliphinter] Fix extraction (closes #18083) [youtube:playlist] Add support for invidio.us (closes #18077) [osnateltv] Update host [zattoo] Arrange API hosts for derived extractors (closes #18035) [README.md] Improve documentation on safe metadata extraction and add more examples [youtube] Add fallback metadata extraction from videoDetails (closes #18052) release 2018.11.03 [ChangeLog] Actualize [ci skip] [laola1tv:embed] Set correct stream access URL scheme (closes #16341) [ehftv] Add extractor (closes #15408) [azmedien] Simplify (closes #17746) [azmedien] Adopt to major site redesign (closes #17745) [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) [twitcasting] Improve extraction and fix issues (closes #17981) [twitcasting] Add extractor [orf:tvthek] Improve extraction and remove unused code (closes #17956, closes #18024) ...
…efore it can be read if it matches expected_status (resolves #17195, closes #17846, resolves #17447)
Make sure you are using the latest version: run
youtube-dl --version
and ensure your version is 2018.08.04. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.Before submitting an issue make sure you have:
What is the purpose of your issue?
Since bpo-15002 (introduced in Python 3.4.1),
HTTPError
s close theirfp
when the error's destroyed. The current implementation ofInfoExtractor._request_webpage
(used byInfoExtractor._download_webpage_handle
and in turn byInfoExtractor._download_
{webpage
,xml
, andjson
}) accommodates forexpected_status
by catchingHTTPError
s and returning thisfp
. Unfortunately, this means subsequent reads against this file object by the caller are unreliable.fp
is an instance ofhttp.client.HTTPResponse
, we read out an empty response body.fp
is an instance ofurllib.response.addinfourl
(for when youtube-dl handles gzip and deflate responses), the attempted read raises aValueError: I/O operation on closed file
exception, as demonstrated inI/O operation on closed file.
error on Python 3.7 #17447.tempfile._TemporaryFileCloser
omits an implementation of__del__
that would closefp
, so reads return successfully. This platform inconsistency has been reported as bpo-34958.Fortunately, the number of extractors that make use of
expected_status
is small; as of 2018.08.04, it's justbbc
,lynda
,markiza
, andtwitch
.Issue encountered whilst debugging reports of problems running @bato3's fix for #17116 on Python 3.7.
The text was updated successfully, but these errors were encountered: