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
Fix for off-by-one bug in urllib.URLopener.retrieve #39265
Comments
This patch fixes an off-by-one bug in the reporthook part of The retrieve method reports reading one more block than it >>> import urllib
>>> def reporter(count, blockSize, fileSize):
... print "c: %i, bs: %i, fs: %i" % (count, blockSize,
fileSize)
...
>>> srcFile = file("/tmp/empty.txt", "wb")
>>> srcFile.close()
>>> urllib.urlretrieve("file:///tmp/empty.txt", "/tmp/new-
empty.txt", reporter)
c: 0, bs: 8192, fs: 0
c: 1, bs: 8192, fs: 0
('/tmp/new-empty.txt', <mimetools.Message instance at
0x5a4f58>)
>>> As a second example, if the file contains 1 byte, the retrieve >>> srcFile = file("/tmp/empty.txt", "wb")
>>> srcFile.write("x")
>>> srcFile.close()
>>> urllib.urlretrieve("file:///tmp/empty.txt", "/tmp/new-
empty.txt", reporter)
c: 0, bs: 8192, fs: 1
c: 1, bs: 8192, fs: 1
c: 2, bs: 8192, fs: 1
('/tmp/new-empty.txt', <mimetools.Message instance at
0x5a50d0>)
>>> This patch also includes some changes to |
Logged In: YES Patch needed slight modification to work against current HEAD; new http://issola.caltech.edu/~t/transfer/transfer/patch-810023- The new regression tests look reasonable. I verified that the new |
Logged In: YES Will review and apply after Xmas vacation. |
Logged In: YES Titus, I'm having difficulty with your link, please attach |
Logged In: YES Reinhold, do you have time for this one? |
Logged In: YES Patch looks good, committed as |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: