[Python-checkins] CVS: python/dist/src/Lib smtplib.py,1.26,1.27

Thomas Wouters python-dev@python.org
Tue, 15 Aug 2000 12:30:38 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory slayer.i.sourceforge.net:/tmp/cvs-serv9148/Lib

Modified Files:
	smtplib.py 
Log Message:

Apply SF patch #101151, by Peter S-K, which fixes smtplib's passing of the
'helo' and 'ehlo' message, and exports the 'make_fqdn' function. This
function should be moved to socket.py, if that module ever gets a Python
wrapper.



Index: smtplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** smtplib.py	2000/08/10 14:02:23	1.26
--- smtplib.py	2000/08/15 19:30:36	1.27
***************
*** 134,152 ****
          re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
  
! def _get_fqdn_hostname(name):
      name = string.strip(name)
      if len(name) == 0:
          name = socket.gethostname()
!         try:
!             hostname, aliases, ipaddrs = socket.gethostbyaddr(name)
!         except socket.error:
!             pass
          else:
!             aliases.insert(0, hostname)
!             for name in aliases:
!                 if '.' in name:
!                     break
!             else:
!                 name = hostname
      return name
  
--- 134,160 ----
          re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
  
! def make_fqdn(name = ''):
!     """Get fully qualified domain name from name.
! 
!     An empty argument is interpreted as meaning the local host.
! 
!     First the hostname returned by socket.gethostbyaddr()
!     is checked, then possibly existing aliases. In case
!     no FQDN is available, hostname is returned.
!     """
      name = string.strip(name)
      if len(name) == 0:
          name = socket.gethostname()
!     try:
!         hostname, aliases, ipaddrs = socket.gethostbyaddr(name)
!     except socket.error:
!         pass
!     else:
!         aliases.insert(0, hostname)
!         for name in aliases:
!             if '.' in name:
!                 break
          else:
!             name = hostname
      return name
  
***************
*** 307,311 ****
          host.
          """
!         self.putcmd("helo", _get_fqdn_hostname(name))
          (code,msg)=self.getreply()
          self.helo_resp=msg
--- 315,322 ----
          host.
          """
!         if name:
!             self.putcmd("helo", name)
!         else:
!             self.putcmd("helo", make_fqdn())
          (code,msg)=self.getreply()
          self.helo_resp=msg
***************
*** 317,321 ****
          host.
          """
!         self.putcmd("ehlo", _get_fqdn_hostname(name))
          (code,msg)=self.getreply()
          # According to RFC1869 some (badly written) 
--- 328,335 ----
          host.
          """
!         if name:
!             self.putcmd("ehlo", name)
!         else:
!             self.putcmd("ehlo", make_fqdn())
          (code,msg)=self.getreply()
          # According to RFC1869 some (badly written)