[Zope-Coders] range-related tests fail in OFS

Guido van Rossum guido@python.org
Fri, 05 Oct 2001 17:09:00 -0400


> On Tue, Oct 02, 2001 at 03:37:25PM -0400, Jeremy Hylton wrote:
> > The testRanges module in OFS has three test failures.  I can't tell
> > who owns this code.  It looks like some simple off-by-one errors, but
> > it isn't obvious if the tests or the code is broken.  Ought to be
> > fixed either way.
> 
> This problem is related to changes in the MultiFile module, see #417176 on
> SourceForge:
> 
>   http://sourceforge.net/tracker/?func=detail&aid=417176&group_id=5470&atid=105470
> 
> In 2.1 (and before) MultiFile would parse a multi-part mime construct and
> return the different parts contained therein with the CRLF that's actually
> part of the mime bounderies with the contained data. The test suite using
> MutiFile to test the range code compensated for this by removing the CRLF
> itself.
> 
> Now MultiFile will remove only a newline, while the range code (correctly)
> generates boundaries with \r\n, and MultiFile ends up returning the parts
> with an additional \r, and the tests fail because of that extra character.

OK, you've convinced me.  Please try this patch.  If it works, mail me
and I'll check it in.

*** multifile.py	2001/09/18 14:34:06	1.19
--- multifile.py	2001/10/05 21:11:16
***************
*** 76,83 ****
          line = self.readahead
          if line:
              self.readahead = self._readline()
!             if not self.readahead and line[-1:] == "\n":
!                 line = line[:-1]
          return line
  
      def _readline(self):
--- 76,86 ----
          line = self.readahead
          if line:
              self.readahead = self._readline()
!             if not self.readahead:
!                 if line[-2:] == "\r\n":
!                     line = line[:-2]
!                 elif line[-1:] == "\n":
!                     line = line[:-1]
          return line
  
      def _readline(self):

--Guido van Rossum (home page: http://www.python.org/~guido/)