[Patches] mailbox.UnixMailbox and rfc822.Message.unixfrom

Thomas Wouters thomas@xs4all.net
Fri, 24 Mar 2000 21:41:24 +0100


--LQksG6bCIzRHxTLp
Content-Type: text/plain; charset=us-ascii


The attached patch fixes a bug in mailbox.UnixMailbox that I hit upon just
this afternoon, tracking a bug in Mailman. mailbox.UnixMailbox eats the
'From ' line in each message, before it passes off the 'subfile' to
rfc822.Message, which means rfc822.Message.unixfrom will be emtpy for all
messages.

I'm not really sure if this is the proper fix, but it seemed more proper
than overriding next() in mailbox.UnixMailbox. I'm also not really sure if
this has been a pending issue, but a quick Deja search revealed nothing of
the kind. Sadly, I've been so swamped in work for the last three weeks that
I haven't been able to read any of the python and mailman lists.

(Barry & other mailman-devel readers, I'll post about the bug in mailman
later, after I get a chance to read all pending mailman-devel mail. The bug
involves moderated lists and their archives.)

I confirm that, to the best of my knowledge and belief, this contribution is
free of any claims of third parties under copyright, patent or other rights
or interests ("claims"). To the extent that I have any such claims, I hereby
grant to CNRI a nonexclusive, irrevocable, royalty-free, worldwide license
to reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part of the
Python software and its related documentation, or any derivative versions
thereof, at no cost to CNRI or its licensed users, and to authorize others
to do so.

I acknowledge that CNRI may, at its sole discretion, decide whether or not
to incorporate this contribution in the Python software and its related
documentation. I further grant CNRI permission to use my name and other
identifying information provided to CNRI by me for use in connection with
the Python software and its related documentation.

-- 
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!

--LQksG6bCIzRHxTLp
Content-Type: text/plain; charset=us-ascii
Content-Description: mailbox.py.diff
Content-Disposition: attachment; filename="mailbox.diff"

Index: mailbox.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/mailbox.py,v
retrieving revision 1.18
diff -c -r1.18 mailbox.py
*** mailbox.py	2000/02/10 17:17:13	1.18
--- mailbox.py	2000/03/24 20:09:23
***************
*** 7,13 ****
  import os
  
  class _Mailbox:
! 
          def __init__(self, fp):
                  self.fp = fp
                  self.seekp = 0
--- 7,13 ----
  import os
  
  class _Mailbox:
!         _skipfirst = 0
          def __init__(self, fp):
                  self.fp = fp
                  self.seekp = 0
***************
*** 29,34 ****
--- 29,37 ----
                                  self.seekp = self.fp.tell()
                                  return None
                          start = self.fp.tell()
+                         if self._skipfirst:
+                                 # Skip the first line when necessary
+                                 self.fp.readline() 
                          self._search_end()
                          self.seekp = stop = self.fp.tell()
                          if start <> stop:
***************
*** 94,106 ****
                  del self.fp
  
  class UnixMailbox(_Mailbox):
! 
          def _search_start(self):
                  while 1:
                          line = self.fp.readline()
                          if not line:
                                  raise EOFError
                          if line[:5] == 'From ' and self._isrealfromline(line):
                                  return
  
          def _search_end(self):
--- 97,111 ----
                  del self.fp
  
  class UnixMailbox(_Mailbox):
!         _skipfirst = 1
          def _search_start(self):
                  while 1:
+                         pos = self.fp.tell()
                          line = self.fp.readline()
                          if not line:
                                  raise EOFError
                          if line[:5] == 'From ' and self._isrealfromline(line):
+                                 self.fp.seek(pos)
                                  return
  
          def _search_end(self):

--LQksG6bCIzRHxTLp--