GH-43374: Fix urlretrieve reporthook to report actual bytes read#142653
GH-43374: Fix urlretrieve reporthook to report actual bytes read#142653savannahostrowski merged 5 commits intopython:mainfrom
Conversation
orsenthil
left a comment
There was a problem hiding this comment.
LGTM. This should be back-ported. This is a safe behavior and an improvement.
|
Thanks @savannahostrowski for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
pythonGH-142653) (cherry picked from commit 68a01f9) Co-authored-by: Savannah Ostrowski <savannah@python.org>
|
GH-143588 is a backport of this pull request to the 3.14 branch. |
pythonGH-142653) (cherry picked from commit 68a01f9) Co-authored-by: Savannah Ostrowski <savannah@python.org>
|
GH-143589 is a backport of this pull request to the 3.13 branch. |
|
There is a call to reporthook just a few lines above before reading the first block. Would it not weird? |
|
Also the docs say
I am not sure that passing the kength of the block that was just read is the 'block size' in this case. Or maybe we should documenty it better. We should also document for blocknum == 0 that we first give the blocksize. |
|
After thinking about this more, I'm inclined to revert this PR. While the old behavior was technically inconsistent, it's been working fine for people, and as @picnixz points out, there are still more edge cases to consider. The change in mental model probably isn't worth the breakage. Also cc: @hugovk for his 2 cents. |
|
There is much of context to bring, I will do a re-review too. |
…ytes read (python#142653)" This reverts commit 68a01f9.
|
No strong opinion either way from me. If we do revert it, let's do so before tomorrow's 3.15a4. |
|
Let's keep the behavior same, that is revert this PR, and close the old bug. We actually didn't want len(block) and wanted a constant https://hg.python.org/cpython/rev/8c48eb0239ca
Sorry, @savannahostrowski - reverting seems better to me. |
… report actual bytes r… (python#143711) Revert "pythonGH-43374: Fix urlretrieve reporthook to report actual bytes read (python#142653)" This reverts commit 68a01f9.


Spelunking through bugs marked with EOL version labels... The docs aren't explicit about what the second argument should represent. The current behavior (always reporting block size 8192) makes progress tracking unreliable since the last block could be smaller. This change makes reporthook report actual bytes read, which is more useful.