[Python-Dev] urlretrieve regression no.2, now in Python 3.3
Gregory P. Smith
greg at krypto.org
Thu Nov 8 00:48:06 CET 2012
On Wed, Nov 7, 2012 at 2:42 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> On 11/7/2012 5:57 AM, anatoly techtonik wrote:
>> urlretrieve has a callback parameter, which takes function with the
>> following prototype:
>> def callback(block_number, block_size, total_size):
>> Where block_size was constant and block_size*block_number gave an exact
>> number of transferred bytes.
> The 3.2 and 3.3 docs both say "The third argument, if present, is a hook
> function that will be called once on establishment of the network connection
> and once after each block read thereafter. The hook will be passed three
> arguments; a count of blocks transferred so far, a block size in bytes, and
> the total size of the file. The third argument may be -1 on older FTP
> servers which do not return a file size in response to a retrieval request."
> The word 'constant' does not appear. The product is still the same.
>> Recent change in Python 3.3 changed the semantic of block_size and broke
>> my `wget` package. http://bugs.python.org/issue16409
> The only change is that blocksize is now reported as 0 before any blocks
> have been transmitted. It is a side-effect of commits for
two changes. the first block size is 0. the last block size is the
number of bytes read.
It is a trivial two line change to undo this and I think it would be
wise. It is difficult to even find documentation on what the
arguments to that callback mean. Look up the urlretrieve() function
docs in 2.7 and 3.3 and it doesn't tell you there or refer you to
anywhere else to find out.
I'm in favor of restoring and documenting the old behavior for this
legacy urlretrieve API to make existing code being ported from 2.7 not
> Terry Jan Reedy
> Python-Dev mailing list
> Python-Dev at python.org
More information about the Python-Dev