[Python-checkins] python/dist/src/Lib urllib2.py,1.61,1.62

loewis at users.sourceforge.net loewis at users.sourceforge.net
Sun Feb 15 16:19:21 EST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26225/Lib

Modified Files:
	urllib2.py 
Log Message:
Patch #711838: Allow non-anonymous ftp urls in urllib2.
Backported to 2.3.


Index: urllib2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -d -r1.61 -r1.62
*** urllib2.py	15 Feb 2004 20:51:39 -0000	1.61
--- urllib2.py	15 Feb 2004 21:19:18 -0000	1.62
***************
*** 116,120 ****
  from urllib import unwrap, unquote, splittype, splithost, \
       addinfourl, splitport, splitgophertype, splitquery, \
!      splitattr, ftpwrapper, noheaders
  
  # support for FileHandler, proxies via environment variables
--- 116,120 ----
  from urllib import unwrap, unquote, splittype, splithost, \
       addinfourl, splitport, splitgophertype, splitquery, \
!      splitattr, ftpwrapper, noheaders, splituser, splitpasswd
  
  # support for FileHandler, proxies via environment variables
***************
*** 1091,1102 ****
          if not host:
              raise IOError, ('ftp error', 'no host given')
!         # XXX handle custom username & password
          try:
              host = socket.gethostbyname(host)
          except socket.error, msg:
              raise URLError(msg)
-         host, port = splitport(host)
-         if port is None:
-             port = ftplib.FTP_PORT
          path, attrs = splitattr(req.get_selector())
          dirs = path.split('/')
--- 1091,1112 ----
          if not host:
              raise IOError, ('ftp error', 'no host given')
!         host, port = splitport(host)
!         if port is None:
!             port = ftplib.FTP_PORT
! 
!         # username/password handling
!         user, host = splituser(host)
!         if user:
!             user, passwd = splitpasswd(user)
!         else:
!             passwd = None
!         host = unquote(host)
!         user = unquote(user or '')
!         passwd = unquote(passwd or '')
! 
          try:
              host = socket.gethostbyname(host)
          except socket.error, msg:
              raise URLError(msg)
          path, attrs = splitattr(req.get_selector())
          dirs = path.split('/')
***************
*** 1105,1109 ****
          if dirs and not dirs[0]:
              dirs = dirs[1:]
-         user = passwd = '' # XXX
          try:
              fw = self.connect_ftp(user, passwd, host, port, dirs)
--- 1115,1118 ----




More information about the Python-checkins mailing list