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

Anthony Baxter anthonybaxter@users.sourceforge.net
Tue, 04 Dec 2001 22:34:36 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv2494

Modified Files:
      Tag: release21-maint
	urllib2.py 
Log Message:
backport 1.17:
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.13.2.1
retrieving revision 1.13.2.2
diff -C2 -d -r1.13.2.1 -r1.13.2.2
*** urllib2.py	2001/07/04 05:18:18	1.13.2.1
--- urllib2.py	2001/12/05 06:34:34	1.13.2.2
***************
*** 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: