-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
While trying to use read1 in urllib3, we discovered that read1 unlike read never closes the response after reading all data when the content length is known (urllib3/urllib3#3235).
import http.client
conn = http.client.HTTPSConnection("www.python.org")
conn.request("GET", "/")
response = conn.getresponse()This runs successfully:
response.read()
assert response.isclosed()This fails:
while response.read1():
pass
assert response.isclosed()CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch
Operating systems tested on:
Linux, macOS, Windows
Linked PRs
- gh-113199: Make
read1andreadlineofHTTPResponseclose IO after reading all data #113200 - [3.12] gh-113199: Make read1() and readline() of HTTPResponse close IO after reading all data (GH-113200) #113259
- [3.11] gh-113199: Make read1() and readline() of HTTPResponse close IO after reading all data (GH-113200) #113260
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error