[Python-Dev] Re: python/dist/src/Lib rfc822.py,1.78,1.79

Guido van Rossum gvanrossum at gmail.com
Tue Feb 8 16:35:17 CET 2005


On Tue, 8 Feb 2005 10:10:49 +0100, Fredrik Lundh <fredrik at pythonware.com> wrote:
> 
> >> @@ -399,9 +393,8 @@
> >>         del self[name] # Won't fail if it doesn't exist
> >>         self.dict[name.lower()] = value
> >>         text = name + ": " + value
> >> -        lines = text.split("\n")
> >> -        for line in lines:
> >> -            self.headers.append(line + "\n")
> >> +        self.headers.extend(text.splitlines(True))
> >> +        self.headers.append('\n')
> >
> > and you're 100% sure that the change in how things are stored
> > in headers won't affect any existing code?
> >
> > (the docstring says that headers contain a list of lines, which is no
> > longer true)
> 
> and the module documentation says:
> 
>     Each line contains a trailing newline. The blank line terminating
>     the headers is not contained in the list.
> 
> which is no longer true (unless I'm missing something here)

This would have been caught if there was a unit test validating what
the documentation says. Why aren't there unit tests for this code? I
think we need to raise the bar for "wholistic" improvements to a
module: first write a unit test if there isn't already one (and if
there is one, make sure that it tests all documented behavior), *then*
refactor. Yes, this would be less fun. It's not supposed to be fun.
It's supposed to avoid breaking code.

Raymond, please roll back that change until this is taken care of.

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


More information about the Python-Dev mailing list