Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11533/Lib Modified Files: urllib.py Log Message: patch [ 810023 ] Fix for off-by-one bug in urllib.URLopener.retrieve Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.167 retrieving revision 1.168 diff -u -d -r1.167 -r1.168 --- urllib.py 24 Aug 2005 18:46:39 -0000 1.167 +++ urllib.py 26 Aug 2005 08:51:34 -0000 1.168 @@ -234,19 +234,17 @@ bs = 1024*8 size = -1 read = 0 - blocknum = 1 + blocknum = 0 if reporthook: if "content-length" in headers: size = int(headers["Content-Length"]) - reporthook(0, bs, size) - block = fp.read(bs) - read += len(block) - if reporthook: - reporthook(1, bs, size) - while block: - tfp.write(block) + reporthook(blocknum, bs, size) + while 1: block = fp.read(bs) + if block == "": + break read += len(block) + tfp.write(block) blocknum += 1 if reporthook: reporthook(blocknum, bs, size)