[Python-checkins] CVS: python/dist/src/Lib urllib2.py,1.16,1.17

Jeremy Hylton jhylton@users.sourceforge.net
2001年8月07日 14:12:27 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv3491
Modified Files:
	urllib2.py 
Log Message:
Fix SF bug [ #447370 ] typo in urllib2.py
Also fix another bug caught by pychecker-- HTTPError() raised when
redirect limit exceed did not pass an fp object. Had to change method
to keep fp object around until it's certain that the error won't be
raised.
Remove useless line in do_proxy().
Index: urllib2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** urllib2.py	2001年08月02日 07:15:29	1.16
--- urllib2.py	2001年08月07日 21:12:25	1.17
***************
*** 437,443 ****
 else:
 return
- nil = fp.read()
- fp.close()
- 
 newurl = urlparse.urljoin(req.get_full_url(), newurl)
 
--- 437,440 ----
***************
*** 451,457 ****
 req.error_302_dict.has_key(newurl):
 raise HTTPError(req.get_full_url(), code,
! self.inf_msg + msg, headers)
 new.error_302_dict.update(req.error_302_dict)
 new.error_302_dict[newurl] = newurl
 return self.parent.open(new)
 
--- 448,460 ----
 req.error_302_dict.has_key(newurl):
 raise HTTPError(req.get_full_url(), code,
! self.inf_msg + msg, headers, fp)
 new.error_302_dict.update(req.error_302_dict)
 new.error_302_dict[newurl] = newurl
+ 
+ # Don't close the fp until we are sure that we won't use it
+ # with HTTPError. 
+ fp.read()
+ fp.close()
+ 
 return self.parent.open(new)
 
***************
*** 526,530 ****
 
 def do_proxy(self, p, req):
- p
 return self.parent.open(req)
 
--- 529,532 ----
***************
*** 660,664 ****
 def __init__(self, passwd=None):
 if passwd is None:
! passwd = HTTPPassowrdMgr()
 self.passwd = passwd
 self.add_password = self.passwd.add_password
--- 662,666 ----
 def __init__(self, passwd=None):
 if passwd is None:
! passwd = HTTPPasswordMgr()
 self.passwd = passwd
 self.add_password = self.passwd.add_password
***************
*** 1052,1056 ****
 
 def build_opener(self):
! opener = OpenerDirectory()
 for ph in self.proxy_handlers:
 if type(ph) == types.ClassType:
--- 1054,1058 ----
 
 def build_opener(self):
! opener = OpenerDirector()
 for ph in self.proxy_handlers:
 if type(ph) == types.ClassType:

AltStyle によって変換されたページ (->オリジナル) /