[Python-checkins] python/dist/src/Lib urllib.py,1.165,1.165.2.1
birkenfeld@users.sourceforge.net
birkenfeld at users.sourceforge.net
Fri Aug 26 10:51:50 CEST 2005
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11552/Lib
Modified Files:
Tag: release24-maint
urllib.py
Log Message:
backport 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.165
retrieving revision 1.165.2.1
diff -u -d -r1.165 -r1.165.2.1
--- urllib.py 11 Oct 2004 13:53:07 -0000 1.165
+++ urllib.py 26 Aug 2005 08:51:39 -0000 1.165.2.1
@@ -228,18 +228,17 @@
self.tempcache[url] = result
bs = 1024*8
size = -1
- blocknum = 1
+ blocknum = 0
if reporthook:
if "content-length" in headers:
size = int(headers["Content-Length"])
- reporthook(0, bs, size)
- block = fp.read(bs)
- if reporthook:
- reporthook(1, bs, size)
- while block:
- tfp.write(block)
+ reporthook(blocknum, bs, size)
+ while 1:
block = fp.read(bs)
- blocknum = blocknum + 1
+ if block == "":
+ break
+ tfp.write(block)
+ blocknum += 1
if reporthook:
reporthook(blocknum, bs, size)
fp.close()
More information about the Python-checkins
mailing list