Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
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 |
Make sure you are using the latest version: run
youtube-dl --versionand 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),
HTTPErrors close theirfpwhen the error's destroyed. The current implementation ofInfoExtractor._request_webpage(used byInfoExtractor._download_webpage_handleand in turn byInfoExtractor._download_{webpage,xml, andjson}) accommodates forexpected_statusby catchingHTTPErrors and returning thisfp. Unfortunately, this means subsequent reads against this file object by the caller are unreliable.fpis an instance ofhttp.client.HTTPResponse, we read out an empty response body.fpis an instance ofurllib.response.addinfourl(for when youtube-dl handles gzip and deflate responses), the attempted read raises aValueError: I/O operation on closed fileexception, as demonstrated in #17447.tempfile._TemporaryFileCloseromits 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_statusis 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.