Repository navigation
Conversation
|
One additional regression boundary is cleanup/error propagation when opening the redirect target fails. A body stub whose On the installed CPython 3.12.16/Linux handler, that fixture calls read(), raises the body EOFError, leaves The new test already covers successful opening across redirect codes. Extending it with a raising target opener would also pin down closing the discarded response before delegation, without swallowing the target failure. AI-assisted source probe; this is method-level evidence on a 3.12 host, not a full PR-build or suite-passing claim. |
|
|
||
| # Don't close the fp until we are sure that we won't use it | ||
| # with HTTPError. | ||
| fp.read() |
There was a problem hiding this comment.
Do we know why we are reading it? What was the reason to read it in the first place?
There was a problem hiding this comment.
Not that I could find. It was already in urllib2's first commit in 2000, and no commit message since explains it; the comment above it was added in 2001 and is about when fp gets closed. The old urllib had the same read from 1995 with no stated reason either (gh-54786), and it was removed there for bpo-8035. Reading the rest of a response is normally done so the connection can be reused, but do_open() sends Connection: close and closes the socket.
I used Claude to help write the fix and its test, and I reviewed both.